From: intersection row and column on
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


From: James A. Fortune on
intersection row and column wrote:
> 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
MPAPoster(a)FortuneJames.com
From: intersection row and column on
Thanks, I removed the parenthesis and it worked

"James A. Fortune" wrote:

> intersection row and column wrote:
> > 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
> MPAPoster(a)FortuneJames.com
>
From: James A. Fortune on
intersection row and column wrote:
> 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
MPAPoster(a)FortuneJames.com