Problem with wdDoNotSaveChanges

C

Chuck

I keep getting a "do you want to save changes" even though I'm using

ActiveDocument.Close wdDoNotSaveChanges

if ActiveDocument contains an image (such as a logo). I get the same
behaviour in different documents with different images. Anybody have any
idea why this would happen and how I can avoid it? Thanks in advance...
 
A

Anand.V.V.N

Hi Chuck,

I suppose if you open the document in read only mode while you opening it
then I suppose you might not get the message.

Any way if you can be more clear on the purpose of opening the document it
would be more clear.

Any way hope this was helpful

Anand
 
C

Chuck

The document is a template. The user is presented with a user form with a
cancel button. If the user clicks cancel the form unloads and the document
closes. The code uses a document object, ie "doc.close wdDoNotSaveChanges"
but I've tested the method on other documents using ActiveDocument.Close and
get the same behaviour. Note that the code is not the issue - the same code
works fine with templates that don't have embedded images.

The question isn't document specific. I'd like to find out why *any*
document with an image (actually a Shape) seems to generate a "do you want to
save changes" dialog regardless of being closed with .Close
wdDoNotSaveChanges -- and how to avoid that behaviour.
 
A

Anand.V.V.N

Hi Chuck,

I created a document with a user form with a cancle button and inserted a
auto shape too in the document and made it a temple, but I am not getting the
dialog box.

If you can show what code you have written it may be helpful.

Anand
 
C

Chuck

As I suspected it's not the code. The problem has to do with the kind of
picture it is (Shape, not InlineShape). Does anyone have any idea why trying
to use wdDoNotSaveChanges with a document that contains a Shape (*not* an
InlineShape) would trigger a message asking whether you want to save changes?

To reproduce the problem:
1. insert a picture from a file into a document
2. right click on the picture
3. choose Format Picture from the popup menu
4. click on the layout tab and make sure the Wrapping Style on the Layout
tab is *not* "In line with text"
5. click OK on the Format Picture dialog
6. save and close the document
7. open the document and run the following sub

Sub CloseNoChangeTest()
ActiveDocument.Close wdDoNotSaveChanges
End Sub
 
A

Anand.V.V.N

Hi Chuck,

I did exactly as you said and called the sub in command button click, and
didn't get any message box. I put that code in the cancle button of the user
form also but the message box didn't show up.

If you can just tell in which event you calling the code, it might be helpful.
 
C

Chuck

Thanks for trying and I don't understand why you're not getting the results
I'm getting because I tested the steps I outlined repeatedly. The only code
necessary to reproduce the behaviour is the single line of code that I
provided -- so posting more code won't be helpful. Did you make sure that the
image is not in-line? That's the crucial point, not where the code is called
from (ie it doesn't matter whether you run the single line
Activedocument.Close wdDoNotSaveChanges from a button on a form or from
Tools>Macros or from within the VBE.

I'm working in Word 2000 SP3 on Win 2000.
 
C

Chuck

By the way, I don't need code to reproduce the problem - if I simply close
the document with an image (NOT an inline image but with wrapping style set
to anything but inline) then I get the "do you want to save changes" message
box, even though I've not made any keystrokes; if the image is inline
however, I don't get the message box. So it's definitely a code issue but a
Word/Shape issue. I'll be switching discussion groups on this issue from now
on.
 
A

Anand.V.V.N

Hi Chuck,

I made sure that the image is not in-line. Could it be the way word is
handling the images?

Anand
 
Top