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

Help - How do I work with 2 or 3 word apps via VBA??

Status
Not open for further replies.

Anna007

Programmer
Nov 29, 2004
38
CA
Hi,

I am populating book-marked documents via VBA. Have a problem however:
I have the following:

Set Mydoc2 = WordApp.Documents.Open(Attach_2)
Worksheets("CEM_Contract").Visible = True
Range("x").Copy
Mydoc2.Bookmarks("y").Range.PasteSpecial
Call Mydoc2.SaveAs(ThisWorkbook.Path & "\xxx.doc", , , , , , vbReadOnly)
Mydoc2.Application.Quit

then:

Mydoc = WordApp.Documents.Open(document)
etc..

I get an error. It complains that the remote server is not accessible or something like this.. I think it's bc of the last line up there... (mydoc2.app.quit).
So, what do I do in this case??!!
How do I work with 2 or 3 different documents that are book-marked?!

I am desparately in need of help.. Please!! :)

Anna
 
So are the files on a Network resource? If so, you may have to provide the essential User/Password in order for you to access the resource. If you go to windows explorer, and navigate to where the Documents are stored, does the User/Pass box popup?

LF

"As far as the laws of mathematics refer to reality, they are not certain; as far as they are certain, they do not refer to reality."--Albert Einstein
 
You've quit the WordApp, and you're not instantiating the Mydoc variable (set statement).Could this perhaps work?

[tt]Set Mydoc2 = WordApp.Documents.Open(Attach_2)
Worksheets("CEM_Contract").Visible = True
Range("x").Copy
Mydoc2.Bookmarks("y").Range.PasteSpecial
Mydoc2.SaveAs ThisWorkbook.Path & "\xxx.doc", , , , , , vbReadOnly)
Mydoc2.close
' Mydoc2.Application.Quit <- remove
set Mydoc = WordApp.Documents.Open(document)[/tt]

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top