Re: why message: Do you want to save the changes you made to xxx.doc? by RB
RB
Sat Oct 29 05:25:59 CDT 2005
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
"Doug Robbins - Word MVP" <dkr@REMOVETHISmvps.org> wrote in message
news:ulSZPUm2FHA.2600@tk2msftngp13.phx.gbl...
> 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
>
> "RB Smissaert" <bartsmissaert@blueyonder.co.uk> wrote in message
> news:eYiORGm2FHA.3420@TK2MSFTNGP15.phx.gbl...
>>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
>>
>>
>>
>>
>
>