akn112
03-05-2007, 09:42 AM
Hi all,
I want run an excel macro from my access database through a access macro. To do this i created a module and input the code below (found through yahoo search). What the (access) macro does is its supposed to
1)run a query
2)export it to an excel file (success) and
3)run the module(below)
4)which runs the excel macro.
For step 3, i tried using the OpenModule command in the macros but it didnt work. When i try to use RunCode, it doesnt recognize any code in my module.:help Forgot to mention, the macro is located on a spreadsheet called personal.xls which opens everytime excel opens (reason for opening 2 xls files).
Sub XLTest()
Dim XL as Object
Set XL = CreateObject("Excel.Application")
XL.Workbooks.Open "C:\My Documents\Macros.xls"
XL.Workbooks.Open "C:\My Documents\ExcelFile.xls"
' If there is more than one macro called TestMacro,
' the module name would be required as in
' XL.Run "Module1.TestMacro"
' to differentiate which routine is being called.
XL.Run "Macros.xls!TestMacro"
End Sub
Thanks!
I want run an excel macro from my access database through a access macro. To do this i created a module and input the code below (found through yahoo search). What the (access) macro does is its supposed to
1)run a query
2)export it to an excel file (success) and
3)run the module(below)
4)which runs the excel macro.
For step 3, i tried using the OpenModule command in the macros but it didnt work. When i try to use RunCode, it doesnt recognize any code in my module.:help Forgot to mention, the macro is located on a spreadsheet called personal.xls which opens everytime excel opens (reason for opening 2 xls files).
Sub XLTest()
Dim XL as Object
Set XL = CreateObject("Excel.Application")
XL.Workbooks.Open "C:\My Documents\Macros.xls"
XL.Workbooks.Open "C:\My Documents\ExcelFile.xls"
' If there is more than one macro called TestMacro,
' the module name would be required as in
' XL.Run "Module1.TestMacro"
' to differentiate which routine is being called.
XL.Run "Macros.xls!TestMacro"
End Sub
Thanks!