kevin1973
asked on
Open Access File From Word
How can I use vba to open a specific file in Access from a Word toolbar button? I've been able use the FollowHyperlink like a url but the window does not maximize. This will need to work for both Word 97 and XP. Any suggestions?
Hi,
In order to complete pauloaquia solution, I would you to use this:
dim obj as object
Dim accApp As Object
Set accApp = CreateObject("access.appli cation")
And at the end do:
Set accApp = Nothing
instead of your
Dim accApp As Access.Application
Set accApp = New Access.Application
That way you will prevent a bug that leave Access in memory when you close the application.
Hope it will help
Phetu
In order to complete pauloaquia solution, I would you to use this:
dim obj as object
Dim accApp As Object
Set accApp = CreateObject("access.appli
And at the end do:
Set accApp = Nothing
instead of your
Dim accApp As Access.Application
Set accApp = New Access.Application
That way you will prevent a bug that leave Access in memory when you close the application.
Hope it will help
Phetu
You're right, I forgot about the Set accApp = Nothing.
Thanks for the correction.
But the New operator will work just as well... (Or at least I think it will).
Thanks for the correction.
But the New operator will work just as well... (Or at least I think it will).
Hi pauloaquia,
No, there's a bug with the New operator that after you the quit instruction, "sometimes" the program stays in memory. Even after you quit you'll see the process still running without having the program runinng. It will be a kind of hidden process.
Few other member as complain about that and it could be applied to Excel or Word also.
That's why i make the precision.
Phetu
No, there's a bug with the New operator that after you the quit instruction, "sometimes" the program stays in memory. Even after you quit you'll see the process still running without having the program runinng. It will be a kind of hidden process.
Few other member as complain about that and it could be applied to Excel or Word also.
That's why i make the precision.
Phetu
Ok, thanks again. You never stop learning...
No problem...that's why we are here for......
ASKER
Using both suggestions I came up with the following which is semi working. It open Access and the mdb file but then it closes it back out. Access doesn't stay open and active.
Sub OpenAcc()
Dim obj As Object
Dim accApp As Object
Set accApp = CreateObject("access.appli cation")
accApp.Visible = True
accApp.OpenCurrentDatabase "d:\mydb.mdb"
accApp.DoCmd.Maximize
accApp.Quit
Set accApp = Nothing
End Sub
Sub OpenAcc()
Dim obj As Object
Dim accApp As Object
Set accApp = CreateObject("access.appli
accApp.Visible = True
accApp.OpenCurrentDatabase
accApp.DoCmd.Maximize
accApp.Quit
Set accApp = Nothing
End Sub
Remove the accApp.Quit line. (But when the procedure ends and the accApp variable goes out of scope I think it will end anyway).
If you want to open a standalone application then I guess you can use
Application.ActivateMicros oftApp xlMicrosoftAccess
but I don't know how to reference the Access application afterwards. But maybe it will shed a light to some other expert...
Paulo
If you want to open a standalone application then I guess you can use
Application.ActivateMicros
but I don't know how to reference the Access application afterwards. But maybe it will shed a light to some other expert...
Paulo
ASKER
I figured out a simple one liner to do the trick:
Shell ("c:\msoffice\office\msacc ess.exe d:\mydb.mdb"), vbMaximizedFocus
Shell ("c:\msoffice\office\msacc
When the problem is solved by the asker (s)he should post a 0 point question in Community Support Topic Area with a link to the first question asking for a moderator to come and close the question and refund the points.
ASKER
I figured out a simple one liner to do the trick:
Shell ("c:\msoffice\office\msacc ess.exe d:\mydb.mdb"), vbMaximizedFocus
Shell ("c:\msoffice\office\msacc
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sub startAcc()
Dim accApp As Access.Application
Set accApp = New Access.Application
accApp.Visible = True
accApp.OpenCurrentDatabase
accApp.DoCmd.Maximize
accApp.Quit
End Sub
Hope this helps
Paulo