Run Excel macro from Access macro?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've set up a macro that executes a query (Open Query), dumps the data into
Excel (Output To), and opens Excel. Within Excel, I have a macro that
rearranges the data and defines the page setup. Is it possible to include the
execution of this Excel macro within the steps of the Access macro? Now I
simply execute the Excel macro manually after the data dump, but it sure
would be nice if this could all be automated.
 
I got his from a previous posting by Ken Snell. It is not an Ecell maro but
vb code

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

Good Luck
 
Back
Top