?
Solved

Open Access File From Word

Posted on 2003-03-05
12
Medium Priority
?
436 Views
Last Modified: 2008-03-10
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?
0
Comment
Question by:kevin1973
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 3
  • +1
12 Comments
 
LVL 9

Expert Comment

by:pauloaguia
ID: 8075375
After adding the Microsoft Access Object Library to your references (Tools -> References) you can use code like the following:

Sub startAcc()
    Dim accApp As Access.Application
   
    Set accApp = New Access.Application
    accApp.Visible = True
    accApp.OpenCurrentDatabase "c:\db1.mdb"
    accApp.DoCmd.Maximize
    accApp.Quit
End Sub

Hope this helps

Paulo
0
 
LVL 2

Expert Comment

by:Phetu
ID: 8077491
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.application")

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
0
 
LVL 9

Expert Comment

by:pauloaguia
ID: 8078736
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).
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Expert Comment

by:Phetu
ID: 8079083
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
0
 
LVL 9

Expert Comment

by:pauloaguia
ID: 8079100
Ok, thanks again. You never stop learning...
0
 
LVL 2

Expert Comment

by:Phetu
ID: 8079110
No problem...that's why we are here for......
0
 

Author Comment

by:kevin1973
ID: 8080037
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.application")
    accApp.Visible = True
    accApp.OpenCurrentDatabase "d:\mydb.mdb"
    accApp.DoCmd.Maximize
    accApp.Quit
    Set accApp = Nothing

End Sub
0
 
LVL 9

Expert Comment

by:pauloaguia
ID: 8080145
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.ActivateMicrosoftApp 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
0
 

Author Comment

by:kevin1973
ID: 8081063
I figured out a simple one liner to do the trick:

Shell ("c:\msoffice\office\msaccess.exe d:\mydb.mdb"), vbMaximizedFocus
0
 
LVL 9

Expert Comment

by:pauloaguia
ID: 8081302
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.
0
 

Author Comment

by:kevin1973
ID: 8081358
I figured out a simple one liner to do the trick:

Shell ("c:\msoffice\office\msaccess.exe d:\mydb.mdb"), vbMaximizedFocus
0
 

Accepted Solution

by:
SpideyMod earned 0 total points
ID: 8081994
PAQ'd and points refunded.

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article helps those who get the 0xc004d307 error when trying to rearm (reset the license) Office 2013 in a Virtual Desktop Infrastructure (VDI) and/or those trying to prep the master image for Microsoft Key Management (KMS) activation. (i.e.- C…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question