Jean-Guy
Wed Jun 07 09:15:59 CDT 2006
Jonathan West was telling us:
Jonathan West nous racontait que :
> "Jean-Guy Marcil" <NoSpam@LeaveMeAlone> wrote in message
> news:%236zg%23ajiGHA.4140@TK2MSFTNGP03.phx.gbl...
>> Jay Freedman was telling us:
>> Jay Freedman nous racontait que :
>>
>>> At the end of the document, set the .Saved property of the template
>>> to True. For example, if the customization context for the toolbar
>>> was Normal.dot, you could write
>>>
>>> NormalTemplate.Saved = True
>>>
>>> That lies to Word and tells it that the template isn't dirty.
>>>
>>> But you have to be careful with this, because the user just might
>>> have made some other change to Normal.dot that they do want to
>>> save, and this would throw it all away. Better to use another
>>> global template as the customization context for the toolbar, and
>>> tell that one that it's "saved".
>>
>> There shouldn't be any problem with user modifications if
>>
>> NormalTemplate.Saved = True
>>
>> is placed immediately after the code that creates the toolbar,
>>
>> This way, any other changes that would change the state of
>> NormalTemplate.Saved
>> would be due to user interaction, and therefore the questions to
>> save the template perfectly legitimate.
>>
>> Right? Did I miss something?
>
> Yes, you missed something. If the user makes other changes, those
> changes *and* the changes to the toolbar are all saved.
DUH! Give me another donut!
Too early in the morning to read the groups, I guess!
Now that I think about it, I wrote some code a while back to avoid such a
thing. I was making changes to a toolbar on the fly (depending on user
actions while editing the document content), but the user was also creating
Autotext entries in the same template.
So I created some routines to check the status of the Template.Saved status
before making my changes, then I made my changes and restored the Saved
status to its initial value.
Then, when closing the document, since I was tracking the value of the Saved
property every time I made a change, I knew if the user needed to be
bothered with the "Do you want to save your template" question.
I used doc variables to save the flags needed to reconstruct the toolbar
when opening the document (doc variables saved with the document, not the
template), this way, along with a Document_Change event, many documents
opened simultaneously could display a different toolbar when going from one
document to the other, even though they were all based on the same template.
This is the second time in a few weeks I forget about this... It will
eventually sink in!
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site:
http://www.word.mvps.org