Run Excel macro with arguments from Access

  • Thread starter Thread starter intersection row and column
  • Start date Start date
I

intersection row and column

I want to run an Excel macro from Access.

This is the syntax used in Access :
Dim xls As Object, xwkb As Object
Dim strFile As String, strMacro As String
strFile = "PERSONAL.XLS"
Set xls = CreateObject("Excel.Application")
xls.Visible = True
Set xwkb = xls.Workbooks.Open(Macro_Path & strFile)
strMacro = "importer_from_Reseachtool"
xls.Run strFile & "!" & strMacro

It works fine.

But now I need to run the same Excel macro with 2 arguments : the year and
the week number.
TheYear = 2008
TheWeek = 26
What is the syntax ?
something like : xls.Run strFile & "!" & strMacro (theYear, TheWeek) ????
of course that doesn't work !!!

thanks for your help
 
intersection said:
I want to run an Excel macro from Access.

This is the syntax used in Access :
Dim xls As Object, xwkb As Object
Dim strFile As String, strMacro As String
strFile = "PERSONAL.XLS"
Set xls = CreateObject("Excel.Application")
xls.Visible = True
Set xwkb = xls.Workbooks.Open(Macro_Path & strFile)
strMacro = "importer_from_Reseachtool"
xls.Run strFile & "!" & strMacro

It works fine.

But now I need to run the same Excel macro with 2 arguments : the year and
the week number.
TheYear = 2008
TheWeek = 26
What is the syntax ?
something like : xls.Run strFile & "!" & strMacro (theYear, TheWeek) ????
of course that doesn't work !!!

thanks for your help

http://groups.google.com/group/comp.databases.ms-access/browse_frm/thread/1bcd8f3e06382521

James A. Fortune
(e-mail address removed)
 
intersection said:
Thanks, I removed the parenthesis and it worked

It's likely that there's a syntax that includes parentheses that works.
Anyway, I'm glad you found a way to make your code work.

James A. Fortune
(e-mail address removed)
 
Back
Top