Run Excel macro with arguments from Access

  • Thread starter intersection row and column
  • 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
 
J

James A. Fortune

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)
 
J

James A. Fortune

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)
 

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