In Access Can't Run Excel Macro Through Automation
Prefix MacroName with filename and an exclamation mark. Depending on the
file name you might also need to embrace it with apostrophes, best to
include them to be on the safe side, eg
sMacro = "'" & sWBname & "'" & "!" & "MacroName"
ExcApp.Run sMacro
where sWBname is the workbook name excluding path
Regards,
Peter T
"scott w t" wrote in message
...
using access 2007 and excel 2007, can't run a macro in excel from access
here is the error message: "The macro may not be available in this
workbook
or all macros may be disabled."
the workbook that contains the macro is in a location that is trusted by
both access and excel
here's the code:
module level declaration
Private ExcApp As New Excel.Application
procedure code
the following works
ExcApp.Visible = TrueExcApp.Run "MacroName"
ExcApp.Workbooks.Open FileSpecification
(the AutoOpen macro runs ok here)
ret = ShowWindow(ExcApp.hwnd, SW_RESTORE)
ret = MoveWindow(ExcApp.hwnd, L, T, R, B, True)
this doesn't work (see error message above)
can anybody help?
|