BuiltInDocumentProperties triggers SAVED flag

S

smac

Word 9.

Hi all,

Accessing BuiltInDocumentProperties sets the document's
Saved flag to False, even when you "just" test the
value. eg.

ActiveDocument.Save

Debug.Print "Before Test : " & ActiveDocument.Saved

If Not ActiveDocument.BuiltInDocumentProperties
(1).value = "plonker" Then

Debug.Print "After Test : " & ActiveDocument.Saved

End If


This is VERY annoying. Does anyone know a fix?

Thanks

smac
 
J

Jean-Guy Marcil

Bonjour,

Dans son message, < smac > écrivait :
In this message, < smac > wrote:

|| Word 9.
||
|| Hi all,
||
|| Accessing BuiltInDocumentProperties sets the document's
|| Saved flag to False, even when you "just" test the
|| value. eg.
||
|| ActiveDocument.Save
||
|| Debug.Print "Before Test : " & ActiveDocument.Saved
||
|| If Not ActiveDocument.BuiltInDocumentProperties
|| (1).value = "plonker" Then
||
|| Debug.Print "After Test : " & ActiveDocument.Saved
||
|| End If
||
||
|| This is VERY annoying. Does anyone know a fix?
||

How is it annoying?

Just add
ActiveDocument.Saved = True
after you check the property...
No?

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
S

smac

-----Original Message-----
Bonjour,

Dans son message, < smac > écrivait :
In this message, < smac > wrote:

|| Word 9.
||
|| Hi all,
||
|| Accessing BuiltInDocumentProperties sets the document's
|| Saved flag to False, even when you "just" test the
|| value. eg.

How is it annoying?

Just add
ActiveDocument.Saved = True
after you check the property...
No?

Oui. Never thought to look if the property was
read/write.

What a dope!!

Merci
 
J

Jean-Guy Marcil

Bonjour,

Dans son message, < smac > écrivait :
In this message, < smac > wrote:

|| -----Original Message-----
|| Bonjour,
||
|| Dans son message, < smac > écrivait :
|| In this message, < smac > wrote:
||
|||| Word 9.
||||
|||| Hi all,
||||
|||| Accessing BuiltInDocumentProperties sets the document's
|||| Saved flag to False, even when you "just" test the
|||| value. eg.
||
|| How is it annoying?
||
|| Just add
|| ActiveDocument.Saved = True
|| after you check the property...
|| No?
|
| Oui. Never thought to look if the property was
| read/write.
|
| What a dope!!
|
| Merci

lol
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
J

Jezebel

Actually, slightly better coding is this:

Dim pSavedState as boolean
pSavedState = ActiveDocument.Saved

.... Check the property ...

'Set saved back to its previous state
ActiveDocument.Saved = pSavedState


Otherwise, if the document had, in fact, been changed, you might be
discarding your changes.
 
J

Jean-Guy Marcil

Bonjour,

Dans son message, < Jezebel > écrivait :
In this message, < Jezebel > wrote:

|| Actually, slightly better coding is this:
||
|| Dim pSavedState as boolean
|| pSavedState = ActiveDocument.Saved
||
|| ... Check the property ...
||
|| 'Set saved back to its previous state
|| ActiveDocument.Saved = pSavedState
||
||
|| Otherwise, if the document had, in fact, been changed, you might be
|| discarding your changes.
||

Very true, but OP had

ActiveDocument.Save

just before checking the property, so we know there weren't any other
changes to be worried about in this particular case.

Or is there something else to worry about even in such a case?

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
J

Jezebel

I took it that the .Save was there to prove the point about checking the
property setting the document to unsaved. In the normal course of
programming, you wouldn't normally save your document as a side-effect of
checking its properties.
 
J

Jean-Guy Marcil

Bonjour,

Dans son message, < Jezebel > écrivait :
In this message, < Jezebel > wrote:

|| I took it that the .Save was there to prove the point about checking the

Ahh... Very possible!
I thought this was some snippet from real code and that he was saving the
document and then, for some reason, checking the property afterwards... Or
that he knew for a fact that the document had been saved when he was
checking the property. I have seen all kinds of "logics"!

But, logically, I agree that your assessment is more probable.

|| property setting the document to unsaved. In the normal course of
|| programming, you wouldn't normally save your document as a side-effect of
|| checking its properties.
||

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

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