Hi,
I'm new to this product and have been able to achieve much of what I want to by using the forums as well as the built-in help. Can someone help with running an Microsoft Access Macro. I use the following code to run an Excel Macro successfully (see below). I would like to know how to do the same for MS Access. Thanks in advance for your help!
//Put this VBScript block at top of script
VBSTART
Sub OpenAndRun(xlFileName, MacroName)
Set xlApp = CreateObject("Excel.Application")
'remove next line to make Excel invisible
xlApp.visible = true
Set xlBook = xlApp.WorkBooks.Open(xlFileName)
xlApp.Run(MacroName)
'Uncomment next line to quit Excel
'xlApp.quit
End Sub
VBEND
//Use this line when you want to run the Excel macro:
VBRun>OpenAndRun,c:\files\myexcel.xls,MyMacro
Run an Access Macro - VB Script
Moderators: Dorian (MJT support), JRL
Run an Access Macro - VB Script
Tom Hughes
Swarovski Optik
Swarovski Optik
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
There is not a similar function in Access. But you can run an Access macro via the command line using the /x switch:
Run>c:\...\msaccess.exe /x macroname
Run>c:\...\msaccess.exe /x macroname
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Run an Access Macro - VB Script
Thanks. So that I understand, do I just use this one command line:
Run>c:\...\msaccess.exe /x macroname
where the DB path is defined (including the DB name), and then specify the macro name within the DB for example:
Run>c:\Databases\mydb.accdb /x mymacro
Do I also use msaccess.exe portion of the statement?
Thanks again!
Run>c:\...\msaccess.exe /x macroname
where the DB path is defined (including the DB name), and then specify the macro name within the DB for example:
Run>c:\Databases\mydb.accdb /x mymacro
Do I also use msaccess.exe portion of the statement?
Thanks again!
Tom Hughes
Swarovski Optik
Swarovski Optik
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Sorry, yes, I left a bit of info out. It would be:
Run>"c:\path\to\access\msaccess.exe" "c:\databases\mydb.accdb" /x myMacro
So you need Access, then the DB, then /x macroname
Run>"c:\path\to\access\msaccess.exe" "c:\databases\mydb.accdb" /x myMacro
So you need Access, then the DB, then /x macroname
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact: