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 2005

Tip: Looking for answers? Try searching our database.

why message: Do you want to save the changes you made to xxx.doc?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
RB Smissaert - 26 Oct 2005 20:14 GMT
I am running some code in Excel to print all Word .doc files in a particular
folder.
With one particular user there is a message popping up when he runs this in
Word 2002, but fine in Word 2003:
Do you want to save the changes you made to xxx.doc?

at the following code.
I presume it is the third line, but I can't reproduce it:

wd.Documents.Open filename:=arrFiles2(i, 2), ReadOnly:=True
wd.ActiveDocument.PrintOut Background:=False
wd.ActiveDocument.Close wdDoNotSaveChanges

Then whether he clicks No or Yes he gets an Error somewhere in a Word
messagebox.
Not sure now what the error is.

Word is declared like this:
Dim wd As Word.Application
Set wd = New Word.Application

Just no idea why this message and error possibly could occur and grateful
for any suggestions.

RBS
Doug Robbins - Word MVP - 26 Oct 2005 20:39 GMT
That third line of code should prevent that message from appearing, so I
don't know why it does.  You might also try including

wd.ActiveDocument.Saved = True

before it.

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

>I am running some code in Excel to print all Word .doc files in a
>particular folder.
[quoted text clipped - 22 lines]
>
> RBS
RB Smissaert - 26 Oct 2005 21:24 GMT
Thanks; I have seen more people that have come across this in Word 2002 and
the solution was always to do as you suggested, so that should be OK then.

RBS

> That third line of code should prevent that message from appearing, so I
> don't know why it does.  You might also try including
[quoted text clipped - 29 lines]
>>
>> RBS
RB Smissaert - 29 Oct 2005 11:25 GMT
I thought that adding wd.ActiveDocument.Saved = True
would have solved this, but unfortunately it hasn't.
Still the same problem.
Any other suggestions?

I will try this code, but I really can't see much difference:

   Dim wd As Word.Application
   Dim wdDoc As Word.Document

   Set wd = New Word.Application
   wd.DisplayAlerts = wdAlertsNone

   for i = 1 to 100

       Set wdDoc = wd.Documents.Open(filename:=arrFiles2(i, 2),
ReadOnly:=True)

       With wdDoc
           .Saved = True    'to avoid a confirmation in Word 2002 !
           .PrintOut Background:=False
           .Saved = True    'to make extra sure
           .Close wdDoNotSaveChanges
       End With

   Next

Another thing I would be interested in is how to get the generated error
(Err.Number and Err.Description) from Word if it was run via automation from
Excel.

RBS

> That third line of code should prevent that message from appearing, so I
> don't know why it does.  You might also try including
[quoted text clipped - 29 lines]
>>
>> RBS
 
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.