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!

Opening Word documents,

Status
Not open for further replies.

jaymri

Technical User
Mar 12, 2010
2
US
Hi.
My code and the solution codes in previous posts here opens word and a specific word document.

My issue is that several word documents get opened at various times, thus many instances of Word running.

Also, if the clerk saves and closes the Word document and leaves Word running the next Word document launched from access also starts a new instance of Word.

I would like to have only 1 instance of Word running and just keep sending Word documents to that instance.

Thanks in advance,

Jay
 
Untested
Code:
public wdApp as word.application

Sub OpenWordDoc(strPath as string)
  Dim wdDoc As Word.Document
  Set wdDoc = wdApp.Documents.Open(strPath)
end sub

Sub OpenWordApp()
On Error Resume Next
 Set wdApp = GetObject(, "Word.Application")
If Err.Number <> 0 Then 'Word isn't already running
 Set wdApp = CreateObject("Word.Application")
End If
On Error GoTo 0
 wdApp.Visible = True
end sub
Open the word App once and store as a public variable, then pass in paths to open other documents.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top