WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

OLE with Access

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Execute a macro in Access

 Keywords:  macro Access

Question:

How do use OLE commands to open a access database and execute a specfic macro? I tried the below code but it doesn't seem to work.
AccessObj = Objectopen("Access.Application")
database = "c:\xbox\xboxlink.mdb"
AccessObj.Open(database)
AccessObj.DoCmd.RunMacro "print" 

Answer:

Close, maybe try...
AccessDB = ObjectOpen("Access.Application")
ADB = AccessDB.Application
database = "c:\xbox\xboxlink.mdb"
ADB.OpenCurrentDatabase (database)

ADB.Visible = 1
ADB.UserControl = 1

;exit

ADBCmd = ADB.docmd
ADBCmd.runmacro("print")

ADB.closecurrentDatabase

;' Close Access with the Quit method on the Application object
ADB.Quit

;' Release the object variable
ObjectClose(AccessDB)

Article ID:   W14921
File Created: 2001:11:08:12:40:58
Last Updated: 2001:11:08:12:40:58