Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Check My Code Please - Execute Access Macro
I guess you are not using Access as a front end to an SQL database ?
Then don't use the "OpenAccessProject" method, use "OpenCurrentDatabase" instead... -- Regards, Luc. "Festina Lente" "Lythandra" wrote: Hi, I'm trying to import in a rather complicated series of queries from Access into Excel. I have set a macro up in the Access database which works fine when I run it from Access. What I am trying to do is get this macro to run from within a specific Excel file. Here is my code which I found on here by searching: Sub RunAccessMacro() Dim appAcc As Access.Application Set appAcc = New Access.Application appAcc.Visible = True appAcc.OpenAccessProject ("C:\Test.mdb") appAcc.DoCmd.RunMacro ("mcr Export To Excel WIP") appAcc.Quit Set appAcc = Nothing End Sub I have also set a reference up within Excel using (Tools - References - Microsoft Access 9.0 Object Library). Now what is happening is that Excel is opening up Access just fine but not the actual specific database. I have even simplified the database location and name just to test it. Does anyone see anything wrong with what I am doing? Thanks |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Check My Code Please - Execute Access Macro
Actually that fixed that part. I'm getting anotehr error now but I think I
can get past this one myself. "PapaDos" wrote: I guess you are not using Access as a front end to an SQL database ? Then don't use the "OpenAccessProject" method, use "OpenCurrentDatabase" instead... -- Regards, Luc. "Festina Lente" "Lythandra" wrote: Hi, I'm trying to import in a rather complicated series of queries from Access into Excel. I have set a macro up in the Access database which works fine when I run it from Access. What I am trying to do is get this macro to run from within a specific Excel file. Here is my code which I found on here by searching: Sub RunAccessMacro() Dim appAcc As Access.Application Set appAcc = New Access.Application appAcc.Visible = True appAcc.OpenAccessProject ("C:\Test.mdb") appAcc.DoCmd.RunMacro ("mcr Export To Excel WIP") appAcc.Quit Set appAcc = Nothing End Sub I have also set a reference up within Excel using (Tools - References - Microsoft Access 9.0 Object Library). Now what is happening is that Excel is opening up Access just fine but not the actual specific database. I have even simplified the database location and name just to test it. Does anyone see anything wrong with what I am doing? Thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How can I use VB code to execute macro when double-clicking cell? | Excel Programming | |||
macro don't execute a step in the code | Excel Programming | |||
how to execute macro from vb 6.0 code? | Excel Programming | |||
access 97 to excel 97: execute macro automation | Excel Programming | |||
access 97 to excel 97: execute macro automation | Excel Programming |