Stephen Byrom
asked on
Rune macro in Excel from Access
HI,
I am trying to run a macro in an Excel workbook from within Access, using a button on an Access form. Can someone help me in finding out why the following code doesn't work?
I have searched google and this site for pointers but I'm at a loss.
I am trying to run a macro in an Excel workbook from within Access, using a button on an Access form. Can someone help me in finding out why the following code doesn't work?
'set variables to open Excel
Dim objXL As Excel.Application
Dim objWkb As Excel.Workbook
Dim objSht As Excel.Worksheet
Dim strFileName As String
strFileName = (GetMyPath() & "Interface2.xlsm")
Set objXL = New Excel.Application
With objXL
Set objWkb = .Workbooks.Open(strFileName, , False, , "thisisthepassword")
For Each objSht In objWkb.Worksheets
objSht.Visible = xlSheetVisible
Next objSht
objWkb.Run "Upload2Dbase"
Set objSht = objWkb.Worksheets("SageDump")
.Visible = True
AppActivate objXL.Caption
objSht.Activate
End With
'destroy objects
Set objSht = Nothing
Set objWkb = Nothing
Set objXL = Nothing
The error I get is that the Object doesn't support this property or method.I have searched google and this site for pointers but I'm at a loss.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks