Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Execute MS Word with a specific .DOC file from Access 1

Status
Not open for further replies.

RangerFan

MIS
May 4, 2000
61
US
I'm trying to execute MS Word and open a specific .doc file using an Access command button. If anyone has any ideas on what the VBA code looks like to accomplish this task, I sure would appreciate it.

Thank you.
 
I think that FollowHyperlink should suit.
 
RangerFan,
Here is a sample [navy]Microsoft: Access Modules (VBA Coding) Forum > [/navy]Closing a Word Document from Access, part of [navy]rj51cxa[/navy]'s original post does exactly what you want.

CMP

(GMT-07:00) Mountain Time (US & Canada)
 
Thanks CautionMP. I tried your code sample and it worked great. The only problem I'm having now is that the document I opened in WORD is a mail merge document, but the mail merge toolbar opens as inactive. Is there a way to have this the toolbar activate when this document opens? If I open the document normally in WORD without going through Access, then the toolbar comes up as active. For me it isn't a problem, but the person that will eventually be using this app is not well versed in how to use mail merge and I want to keep it as easy as possible for them.

Thanks again. Any help would be further appreciated.

 
RangerFan,
No idea, to replicate I did this in Access 2000 (Word is also 2k) and the mail merge toolbar and document functions normally.
Code:
Sub TestMerge()
Dim objWord As Object
Dim strDocumentName As String

strDocumentName = "C:\MergeTest.doc"

Set objWord = CreateObject("Word.Application")
With objWord
  .Visible = True
  .Documents.Open strDocumentName
End With
Set objWord = Nothing
End Sub

CMP

(GMT-07:00) Mountain Time (US & Canada)
 
Hi CautionMP:

I tried the new code you sent, but it produced the same result. When WORD opens the document I don't get the customary message telling me what data source is being used, and while the mail merge tool bar is present, almost all the options appear as inactive. I'll play around with it some more and see what happens. This would be a nice to have, but I can use a work around. If figure it out, I'll let you know.

Thanks for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top