
Run Excel Macro through Access VBA
Glad you found the answer. Sorry about the (). I've not had a problem with
that when I've used them.
--
Ken Snell
<MS ACCESS MVP>
Quote:
> Found the answer.. the line " xlx.Run
> "CDSDataCleanMacros.xls!CleanTradeandRefEntityData()" " does not need the
()
> in it.. works fine from there.. thanks a lot!!!!
> > Ken.. Thanks for this mock code. I have applied to my existing needs
> and
> > can not get past the xlx.Run statement. When the code gets to that
point
> > it says:
> > Run-time error '1004':
> > The macro 'CDSDataCleanMacros.xls!CleanTradeandRefEntityData()' cannot
be
> > found.
> > Do you possibly now what is wrong with this piece of the code given my
> code
> > below, based on your suggestion????
> > Public Sub CleanDownloadedTradeDatainExcel()
> > Dim xlx As Object, xlw As Object
> > Set xlx = CreateObject("excel.application")
> > Set xlw =
> > xlx.Workbooks.Open("F:\GFIR\CDS\Development\CDSDataCleanMacros.xls")
> > xlx.Run "CDSDataCleanMacros.xls!CleanTradeandRefEntityData()"
> > xlw.Close False
> > xlx.Quit
> > Set xlw = Nothing
> > Set xlx = Nothing
> > End Sub
> > Thanks.. SJH
> > > Here's some sample code for opening an EXCEL workbook and running a
VBA
> > > macro that's in the workbook in a public module:
> > > Public Sub TestMacroRun()
> > > Dim xlx As Object, xlw As Object
> > > Set xlx = CreateObject("excel.application")
> > > Set xlw = xlx.workbooks.Open("C:\Filename.xls")
> > > xlx.Run "Filename.xls!MacroName()"
> > > xlw.Close False
> > > xlx.Quit
> > > Set xlw = Nothing
> > > Set xlx = Nothing
> > > End Sub
> > > --
> > > Ken Snell
> > > <MS ACCESS MVP>
> > > > Is there a way, via a command or another way, to open and run an
Excel
> > > macro
> > > > stored in a workbook through Access???