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

R

RB Smissaert

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
 
D

Doug Robbins - Word MVP

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.

--
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
 
R

RB Smissaert

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
 
R

RB Smissaert

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
 

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