Problems with document and application object

  • Thread starter News.Microsoft.com
  • Start date
N

News.Microsoft.com

How do I tie a document object to the one I just opened. The document I end
up saving is blank. Somehow I need to get the one I just opened into the
document object that is being saved.


Dim MyWord As Word.Application
Dim WordDoc As Word.Document

Set MyWord = New Word.Application
With MyWord
.Documents.Open ("c:\test.doc")
Set WordDoc = MyWord.Documents.Add
WordDoc.SaveAs "c:\test1.doc"
DoEvents

Set MyWord = Nothing
Set WordDoc = Nothing
 
T

Tony Strazzeri

Set a variable to the document you open and then use that handle to
manipulate the correct document.

eg
Dim DocOpened As Word.Document
Set DocOpened = .Documents.Open("c:\test.doc")

you can then do
DocOpened.Save etc.

Cheers
TonyS.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top