I want to click a button on a form, and run a macro that is in Excel. The following code will OPEN the document, but NOT run the macro. I have to manually click the macro button to work. Help!
Here's the code I borrowed from a website:
Code
Option Compare Database
Private Sub cmdImport_Click()
Dim objXL As Object, x
On Error Resume Next
Set objXL = CreateObject("Excel.Application"
With objXL.Application
.Visible = True
'Open the Workbook
.Workbooks.Open "H:\pwilliams\Personal\Import.xls"
'Include CARMA in menu, run AutoOpen
.activeworkbook.RunAutoMacro
x = .Run("import", 0)
End With
Set objXL = Nothing
End Sub
Here's the code I borrowed from a website:
Code
Option Compare Database
Private Sub cmdImport_Click()
Dim objXL As Object, x
On Error Resume Next
Set objXL = CreateObject("Excel.Application"
With objXL.Application
.Visible = True
'Open the Workbook
.Workbooks.Open "H:\pwilliams\Personal\Import.xls"
'Include CARMA in menu, run AutoOpen
.activeworkbook.RunAutoMacro
x = .Run("import", 0)
End With
Set objXL = Nothing
End Sub