Hello,
This can't be that hard! Could someone give me the code to run a macro in my Personal.xls from my Access module? I have created a query in Access, exported it to a network drive, I can open it, but now need to format it.
This is what I have, it works fine to open the Personal.xls but not run the Format_TerrList ing macro.
(Previous code here......)
Dim oXL As Object
Dim oExcel As Object
Dim sFullPath As String
Dim sPath As String
Dim sMacros As String, tMacros As String
'Dim CurrentProject As String
' Create a new Excel instance
Set oXL = CreateObject("E xcel.Applicatio n")
' Only XL 97 supports UserControl Property
On Error Resume Next
oXL.UserControl = True
On Error GoTo 0
' Full path of excel file to open
On Error GoTo ErrHandle
sPath = "P:\TerritoryLi stings\"
sFullPath = sPath & mFilename
sMacros = "V:\Documen ts and Settings\CBalse r\Application Data\MicroSoft\ Excel\XLSTART\P ERSONAL.XLS"
DoCmd.RunMacro "Format_TerrLis ting" ' this doesn't work
' Open it
With oXL
.Visible = True
.workbooks.Open (sFullPath)
.workbooks.Open (sMacros)
End With
Thanks for setting me straight with the correct syntax and code!!
CBalser
This can't be that hard! Could someone give me the code to run a macro in my Personal.xls from my Access module? I have created a query in Access, exported it to a network drive, I can open it, but now need to format it.
This is what I have, it works fine to open the Personal.xls but not run the Format_TerrList ing macro.
(Previous code here......)
Dim oXL As Object
Dim oExcel As Object
Dim sFullPath As String
Dim sPath As String
Dim sMacros As String, tMacros As String
'Dim CurrentProject As String
' Create a new Excel instance
Set oXL = CreateObject("E xcel.Applicatio n")
' Only XL 97 supports UserControl Property
On Error Resume Next
oXL.UserControl = True
On Error GoTo 0
' Full path of excel file to open
On Error GoTo ErrHandle
sPath = "P:\TerritoryLi stings\"
sFullPath = sPath & mFilename
sMacros = "V:\Documen ts and Settings\CBalse r\Application Data\MicroSoft\ Excel\XLSTART\P ERSONAL.XLS"
DoCmd.RunMacro "Format_TerrLis ting" ' this doesn't work
' Open it
With oXL
.Visible = True
.workbooks.Open (sFullPath)
.workbooks.Open (sMacros)
End With
Thanks for setting me straight with the correct syntax and code!!
CBalser
Comment