Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

running a module from an automated macro 1

Status
Not open for further replies.

dhamspec

Programmer
Jan 29, 2002
13
CA
Hi, I am trying to run an excel macro from within an automated access macro. Through some VB code I got from another forum I was able to write what I thought was a macro in Access that does the job, however it has saved as a module. I have not yet taken Visual Basic (start on April 7) so I don't really understand the difference between a macro and a module. My dilemma at this point is to get this module to run from within the access macro I am using, I have a command for OpenModule but that doesn't run it, I thought perhaps RunCode but that doesn't seem to do the trick. I have included the code below, any help is appreciated

Sub testx()
Dim oEx As Object
Set oEx = CreateObject("Excel.Application")
' oEx.Visible = True
oEx.Workbooks.Open "c:\vb.xls"
oEx.Run "Macro1"
oEx.Quit
Set oEx = Nothing
End Sub
 
In Access a module is a collection of VBA procedures associated either with a form/report or globally with the whole application. A Macro is a set of actions and parameters that you create, view and edit in window dialogues.

In Access you would use RunMacro to run a macro. Perhaps Excel does the same?

 
Hi, I am trying to run this in Access. When I try to use runmacro it does not give me the option of running this because it is a module. I would love it just to be a macro so I can use runmacro.
 
Your code seems to be opening Excel and trying to run an Excel macro. Surely the macro must reside within Excel?

 
The original macro resides in Excel however as part of a bigger macro in access I want to run the excel macro from access which the code above does as a module, however in the automated Access Macro which I want to start with running the excel Macro I cannot find a way to run a module
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top