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 MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

From Ms Access Open a Word document at a Bookmark 1

Status
Not open for further replies.

DavidB12345

Technical User
Mar 14, 2003
4
US
Hi,

I am trying to open a Word document at a bookmark location from a button on an Access Form.

The following code works to open the document:

Call Shell("winword ""c:\folder\myDocument.doc""",1)

The Word Macro that goes to the bookmark is called FilePrep1 and runs correctly when I execute it in Word. There is a \mMACROname switch to run a macro from the command line when you start Word, BUT I HAVE TRIED IT IN THE ABOVE CODE AFTER winword AND AFTER EACH QUOTATION MARK.
The document will open but it never executes the macro.

Any suggestions. Thanks...
 
I figured out how to open Word at the Bookmark from Access by experimenting with starting Word from the RUN command. Apparently, I hadn't used all the possible choices for inserting the macro switch. The following steps work:

First, Create the Bookmark in Word: (bookmark = FilePrep)

Sub FilePrep1()
' FilePrep1 Macro
' Macro recorded 3/11/2003 by NYC

Selection.GoTo What:=wdGoToBookmark, Name:="FilePrep"
With ActiveDocument.Bookmarks
.DefaultSorting = wdSortByName
.ShowHidden = False
End With
End Sub


Then, create a button in Access and attach this code:

Private Sub btnTreatCommencedDoc_Click()

Call Shell ("WINWORD.EXE ""c:\folder\file.doc"" /mMacroName1 ", 1)

End Sub


Be sure to keep all the QUOTATION MARKS " " .

The macro is saved in the NORMAL.dot template.

I use this code when I need to extensively document an application. Word provides a lot for formatting choices than a text box on an Access form.

Hope you find this information useful.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top