Private myExcel As Excel.Application
private sub Tests()
Set myExcel = GetObject(, "excel.application")
If Err.Number <> 0 Then
Err.Clear
Set myExcel = CreateObject("excel.application")
If Err.Number <> 0 Then
MsgBox "Excel打开出错,或没有正确安装。", vbOKOnly + 16, "错误:"
End
End If
End If
myExcel.Workbooks.Open "c:\wyp.xls"
myExcel.Run "Macro1"
myExcel.Visible = True
Set myExcel = Nothing
end sub