Run Excel macro from Access macro?

S

Sherry S.

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.
 
E

Eric Blitzer

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top