Trigger a Excel Macro from within Access

J

johnb

Hi all

In an Access XP Procedure how do I trigger a macro stored
in a Excel SS? It must be easy but my brain is not in
full working order today.

TIA
johnb
 
K

Ken Snell [MVP]

This may get you started:

Dim xls As Object, xwkb As Object
Dim strFile As String, strMacro As String
strFile = "ExcelFilename.xls"
strMacro = "MacroName"
Set xls= CreateObject("Excel.Application")
xls.Visible = True
Set xwkb = xls.Workbooks.Open("C:\" & strFile)
xls.Run strFile & "!" & strMacro
xwkb.Close False
Set xwkb = Nothing
xls.Quit
Set xls = Nothing
 
J

johnb

Yes, many thanks Ken.

johnb
-----Original Message-----
This may get you started:

Dim xls As Object, xwkb As Object
Dim strFile As String, strMacro As String
strFile = "ExcelFilename.xls"
strMacro = "MacroName"
Set xls= CreateObject("Excel.Application")
xls.Visible = True
Set xwkb = xls.Workbooks.Open("C:\" & strFile)
xls.Run strFile & "!" & strMacro
xwkb.Close False
Set xwkb = Nothing
xls.Quit
Set xls = Nothing

--

Ken Snell
<MS ACCESS MVP>




.
 
Top