Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / October 2006

Tip: Looking for answers? Try searching our database.

Problems with document and application object

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
News.Microsoft.com - 01 Oct 2006 15:45 GMT
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
Tony Strazzeri - 01 Oct 2006 17:57 GMT
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.

> 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
[quoted text clipped - 12 lines]
> Set MyWord = Nothing
> Set WordDoc = Nothing
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.