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

How do I work with 2 Word Documents in Access?

Status
Not open for further replies.

newboy18

MIS
Apr 11, 2003
45
GB
Please help, I have a routine that opens a Word doc from Access, but now I want to open 2 documents at the same time. How do I set 2 variables so that I can activate one, then switch and activate the other?

Public Const WordDot As String = "c:\Test.dot"

Dim objWord As Word.Application
Set objWord = CreateObject("Word.Application")
Documents.Open WordDot, , ReadOnly
ActiveDocument.Select

ActiveDocument.Close (wdDoNotSaveChanges)
objWord.Quit
Set objWord = Nothing
 
Try this:

Dim oWord as New Word.Application

Private Sub OpenDocs()
Dim docFile1 as Document, docFile2 as Document

Set docFile1 = oWord.Open("c:\File #1",,ReadOnly)
Set docFile2 = oWord.Open("c:\File #2",,ReadOnly)

'Select which file you want active at the time
docFile1.Select (or could be docFile2.Select)

End Sub

Hope this gets you on the right track!
Shane
 
Thanks Shane,
I tried something like that but it wont accept "objWord.Open" in the 4th line:

When I tried to run it it gives the error:
"Method or data member not found"

Dim objWord As Word.Application
Set objWord = CreateObject("Word.Application")
Dim docType1 As Document, docType2 As Document
Set docType1 = objWord.Open(WordDot, , ReadOnly)
Set docType2 = objWord.Open(WordDot, , ReadOnly)
docType1.Select
 
I found that it would accept:

Set docType1 = objWord.Documents.Open(WordDot, , ReadOnly)
But then "docType1.Select" would not work
 
Has anyone else got a solution to my problem please ?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top