Sub 在Access里面运行Excel的事件()
Dim BBnam1 As String
On Error GoTo errmsg
BBname1 = CurrentProject.Path & "\支出.xls"
If Dir(BBname1) = "" Then
MsgBox "文件:[" & BBname1 & "]无法找到!", 0, "系统提示"
Exit Sub
End If
Dim oExcel As Object
Dim oBook As Object
Set oExcel = CreateObject("Excel.Application")
oExcel.Visible = True '可见
Set oBook = oExcel.Workbooks.Open(BBname1)
oExcel.Run "测试" ''''运行excel里面的宏
oExcel.Quit '''退出
Set oSheet = Nothing
Set oBook = Nothing
Exit Sub
errmsg:
oExcel.Quit '''退出
Set oSheet = Nothing
Set oBook = Nothing
MsgBox Err.Description
End Sub