Trigger a Excel Macro from within Access

  • Thread starter Thread starter johnb
  • Start date Start date
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
 
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
 
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>




.
 
Back
Top