How to open MS Access in Runtime using Excel VBA?
Asked Answered
H

1

6

I'm struggling on how to open MS Access Runtime using VBA, from an Excel file.

You can open the full version of Access using CreateObject("Access.Application"), but that doesn't open Access in Runtime.

We only have Microsoft Access Runtime installed in some computers, because that's all we need to use the front-ends we've developed. So we need to open the accdb files using MS Access Runtime, but from Excel.

Any help is appreciated, thank you

Hypoglycemia answered 20/2, 2017 at 18:24 Comment(11)
Can you clarify what you mean with "in runtime"? Is Access supposed to magically open with a specific database and run a specific macro without you telling it?Paine
Yes - we only have Microsoft Access Runtime installed in some computers, because that's all we need to use the front-ends we've developed.So we need to open the accdb files using MS Access Runtime, but from Excel.Hypoglycemia
I'd suggest you edit your question to include that somewhat crucial information.Paine
I'll do that - thank you!Hypoglycemia
Awesome - down+close votes retracted. And heck, have an upvote!Paine
Do you need to programmatically interact with the objects? Or is it enough just to open the file? Perhaps using Shell commands?Sheehan
Just open the files. I'll look into shell commands, thank youHypoglycemia
Windows Script Host Object Model WshShell.Exec, or Microsoft Shell Controls and Automation Shell.ShellExecuteSheehan
@ZevSpitz awesome, thanks!!Hypoglycemia
@ZevSpitz that would be an answer...Paine
@Mat'sMug Not really, because it's only clear from the comments that the OP doesn't need programmatic access.Sheehan
S
3

You can use the Shell to open a file, as if you typed that command into window's command prompt.

d = Shell("pathToFile\Database1.accdb /runtime", vbNormalFocus)

Another option you could use to open in the file in runtime (if someone opens it from the folder or through some other method without the /runtime switch) would be to change the file extension to .accdr. This will always force runtime.

Skirl answered 20/2, 2017 at 19:27 Comment(1)
Thank you so much! I did something very similar and it's working now CreateObject("WScript.Shell").Run ("""pathToFile\Database1.accdb""")Hypoglycemia

© 2022 - 2024 — McMap. All rights reserved.