I am working on a script which needs to run an MS Access macro. Typically I do this with RunProgram> as ExecuteFile doesn't have a macro argument.
My issue is that I won't know which version of MS Office the user will have. I guess I could look for MSACCESS.EXE in multiple folders, but it's harder than I anticipated finding a complete list of installation folders for both 64 bit and 32 bit.
Is there a way I can identify the installation location for Access programatically?
Automatically Detect MS Office Install Location
Moderators: Dorian (MJT support), JRL
Automatically Detect MS Office Install Location
Thanks,
Josh
Josh
- Dorian (MJT support)
- Automation Wizard
- Posts: 1380
- Joined: Sun Nov 03, 2002 3:19 am
- Contact:
Re: Automatically Detect MS Office Install Location
How about something like this? Using DOS seems to work pretty well, and running this only took a second or so.
View Snippet Page
View Snippet Page
Yes, we have a Custom Scripting Service. Message me or go here
- Grovkillen
- Automation Wizard
- Posts: 1131
- Joined: Fri Aug 10, 2012 2:38 pm
- Location: Bräcke, Sweden
- Contact:
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Re: Automatically Detect MS Office Install Location
ExecuteFile DOES let you pass parameters - see help file:ueberyak wrote:I am working on a script which needs to run an MS Access macro. Typically I do this with RunProgram> as ExecuteFile doesn't have a macro argument.
https://www.mjtnet.com/manual/executefile.htm
"ExecuteFile>file_to_execute[,parameters]"
So you can simply do this:
Code: Select all
ExecuteFile>%USERDOCUMENTS_DIR%\MyDb.accdb,/x Macro1
Another way would be to use VBScript:
Code: Select all
VBSTART
Sub RunMacro(accessfile,macroname)
dim accessApp
set accessApp = createObject("Access.Application")
accessApp.OpenCurrentDataBase(accessfile)
'comment next line out if you don't want access to be visible
accessApp.visible = true
accessApp.DoCmd.RunMacro macroname
'you can run a subroutine or function in module code instead if you want:
'accessApp.run "routinename"
accessApp.Quit
set accessApp = nothing
End Sub
VBEND
VBRun>RunMacro,%USERDOCUMENTS_DIR%\MyDb.accdb,Macro1
http://help.mjtnet.com/article/19-conve ... o-vbscript
But if you do want to get the path, how about query the mime-type in the registry:
Code: Select all
RegistryReadKey>HKEY_CLASSES_ROOT,ms-access\shell\open\command,,accPath
ExtractFilePath>accPath,accPath
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?