Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Open Access File From Word

Posted on 2003-03-05
12
Medium Priority
?
437 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
  • 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
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Microsoft's Excel has many features that most people will never need nor take advantage of.  Conditional formatting is one feature that you may find a necessity once you start using it.
This holiday season, we’re giving away the gift of knowledge—tech knowledge, that is. Keep reading to see what hacks, tips, and trends we have wrapped and waiting for you under the tree.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…

580 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