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

Open word document from Access

Status
Not open for further replies.

evansc

Technical User
Jul 19, 2004
42
US
Is it possible to tell Access to not only open Word, but to open a specific document in Word? When I try that, I get told it's an invalid command. But I am able to open up Word.
 
Hi evansc

Have you tried using hyperlinking the text to a particular word file?
 
I do it like this....

Shell "c:/full path/winword.exe" "c:/document path/filename.doc", vbMaximizedFocus

Randy
 
Thanks for your responses! I chose not to do a hyperlink because I want more than just a document to open. First I turn the warnings off, then SQL runs to make a table (deleting the previous table of the same name.), then I open the appropriate document in word (already set up to mail merge to the table I just made), then I turn warnings back on and close out of Access so the mail merge is possible. The only thing not working is calling up the particular document.

Randy, I tried what you suggested, but it tells me the file is not found. It must be something in the way I did the punctuation or something, because I just copied the file name and path from the document itself so it wouldn't have typos. Here's what I have--do you have any ideas?

DoCmd.SetWarnings (WarningsOff)
DoCmd.RunSQL "SELECT tblCourses.CourseID, --REALLY LONG SQL HERE.
Call Shell("C:\Program Files\Microsoft Office\Office10\WINWORD.EXE""\\documents\Offices\Judicial & Court Services\Judicial College\Shared Project Folders\Templates\Letters & Accessories\Conf Letter Mail Merge.doc", 1)
DoCmd.SetWarnings (WarningsOn)
DoCmd.Quit acSave
DoCmd.Close ,
 
Don't include Call before the Shell command.

You need a space between the arguments (application path, document path).

Shell "C:\Program Files\Microsoft Office\Office10\WINWORD.EXE" "C:\documents\Offices\Judicial & Court Services\Judicail College\Shared Project Folders\Templates\Letters & Accessories\Conf Letter mail Merge.doc", acMaximizedFocus

Randy
 
Whenever I publish a report from Microsoft Access 2000 to Microsoft Word 2000 the right margins change from 1 inch to 2 inches.
 
Regarding a launch from Access:
Here's one I did with a control ... has a little bit of error handling. Cares where Word file is but does not care where app is ...
Private Sub RunMswordInScool_Click()

Dim LWordDoc As String
Dim oApp As Object

'Path to the word document
LWordDoc = "c:\letters\iss.doc"

If Dir(LWordDoc) = "" Then
MsgBox "The Document was not found. Check Letters folder on C:\"

Else
'Create an instance of MS Word
Set oApp = CreateObject(Class:="Word.Application")
oApp.Visible = True

'Open the Document
oApp.Documents.Open filename:=LWordDoc
End If


End Sub

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top