Answered by:
Open Access 365 file using VBScript

Question
-
Hi,
I'm on a machine that has both Access 2003 and Access 365 installed. I am trying to open an .accdb file with the following script, but it defaults to Access 2003. Is there a way to force it to open in Access 365?? If I just double-click on an .accdb it will open no problem.
Dim fullPath fullPath = "C:\Inspection_Data\Tablet_LSPA and SWP Inspections.accdb" Dim msAccess Set msAccess= CreateObject("Access.Application") msAccess.UserControl = True msAccess.OpenCurrentDatabase(fullPath)
Thanks!
Brian
Thursday, November 29, 2018 8:45 PM
Answers
-
Ah, this works. Use Wscript.Shell and remove any spaces from the filename:
Dim fullPath
fullPath = "C:\Inspection_Data\Tablet_LSPAandSWPInspections.accdb"
Dim wshShell
Set wshShell = CreateObject("WScript.Shell")
wshShell.Run fullPathThanks!
Brian
- Marked as answer by Khabibulla Friday, November 30, 2018 2:26 PM
Friday, November 30, 2018 2:25 PM
All replies
-
You might try this version, and adjust the version number until it works. I can't test it with O365 myself, as I don't have that installed.
Set msAccess = CreateObject("Access.Application.16")
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.htmlThursday, November 29, 2018 9:44 PM -
Thanks Dirk. I did a bit of digging and on my machine I have the options of .Application, .Application.11 or .Application.16
When I look in the system registry the .16 seems to have an association to the MSACCESS.exe which is the Access 365 installation files, but the code still tries to open it up in 2003.
I'll keep trying things, but if you can think of anything please let me know.
Thanks!!
Brian
Friday, November 30, 2018 1:51 PM -
Ah, this works. Use Wscript.Shell and remove any spaces from the filename:
Dim fullPath
fullPath = "C:\Inspection_Data\Tablet_LSPAandSWPInspections.accdb"
Dim wshShell
Set wshShell = CreateObject("WScript.Shell")
wshShell.Run fullPathThanks!
Brian
- Marked as answer by Khabibulla Friday, November 30, 2018 2:26 PM
Friday, November 30, 2018 2:25 PM -
Excellent! I first saw your post that my suggestion didn't work for you, and I was thinking of suggesting something along this lines, but you beat me to it. I'm glad you found a solution.
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.htmlFriday, November 30, 2018 4:17 PM