Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Run Access Macro from Excel - VBA

5 views
Skip to first unread message

Phillip Hurst

unread,
Jul 17, 2002, 4:06:35 PM7/17/02
to
I am trying to run a Macro named Main that I have created
in Access from excel, using VBA. The code I am using is

Sub AccessTest1()
Dim A As Object
Set A = CreateObject("Access.Application")
A.Visible = False
A.OpenCurrentDatabase ("C:\mainCofAwork.mdb")
A.Run "Main"
End Sub

The code runs until it Reaches the A.Run.
That is when I receive the following error message
Microsoft Access can't find the procedure 'Main.@'
You may have used the run method in visual basic but
entered an invalid procedure name,
or you used the run method without first opening a
database.*You tried to use the OpenModule
method, but you used an invalid procedure name.

Thanks for your help,

Phillip

Tim

unread,
Jul 18, 2002, 10:59:33 PM7/18/02
to
Phillip,

When you say you want to run a "Macro" do you mean a VBA
procedure within Access or a "macro" stored in Acces which
is a separate object Access tracks like a table, query,
etc.

If it's a truly a macro, which is not treated the same as
VBA code, then use the command:

A.DoCmd.RunMacro "Main"

If it's actualy VBA code, then your code below should work
save any spelling errors. Also make sure the VBA code is
a public routine if it is VBA.

-Tim

>.
>

0 new messages