Problems with document and application object

Problems with document and application object

Post by News.Micro » Mon, 02 Oct 2006 23:45:52


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
 
 
 

Problems with document and application object

Post by Tony Straz » Tue, 03 Oct 2006 01:57:09

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.