B
Bryon
Hi,
I'm attempting to open an excel workbook from access and run a macro.
I can open the workbook fine by hand and I know that path is correct.
Each time the code executes I get:
Run-time error ‘1004': Cannot access ‘import.xls'.
I found one article from Microsoft that tells about a security change
in excel allowing VBA projects to execute a macro and I have already
made this change.
If anyone could help I would greatly appreciate it.
Private Sub Refresh_Data_Click()
Dim xls As Object, xwkb As Object
Dim strFile As String, strMacro As String
strFile = "import.xls"
strMacro = "Update"
Set xls = CreateObject("Excel.Application")
xls.Visible = True
Set xwkb = xls.Workbooks.Open("E:\" & strFile)
xls.Run strFile & "!" & strMacro
xwkb.Close False
Set xwkb = Nothing
xls.Quit
Set xls = Nothing
End Sub
I'm attempting to open an excel workbook from access and run a macro.
I can open the workbook fine by hand and I know that path is correct.
Each time the code executes I get:
Run-time error ‘1004': Cannot access ‘import.xls'.
I found one article from Microsoft that tells about a security change
in excel allowing VBA projects to execute a macro and I have already
made this change.
If anyone could help I would greatly appreciate it.
Private Sub Refresh_Data_Click()
Dim xls As Object, xwkb As Object
Dim strFile As String, strMacro As String
strFile = "import.xls"
strMacro = "Update"
Set xls = CreateObject("Excel.Application")
xls.Visible = True
Set xwkb = xls.Workbooks.Open("E:\" & strFile)
xls.Run strFile & "!" & strMacro
xwkb.Close False
Set xwkb = Nothing
xls.Quit
Set xls = Nothing
End Sub