removing message do you want to save changes

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have created a template and when i create a document based on the template and then save the document i am asked if i want to save the template. Then when i close the document i am asked if i want to save changes to xxxxx.dot
Can i get rid of either of these or both
I have seen some code in an earlier answer (Jean-Guy Marcil) and tried that but it doesn't have any effect

Many thanks
 
Hi cw,

I do not remember the post you are referring to... I browse through a few
NG... ;-)

If you have done so already, could you be so kind as to post all the code
contained in your template. If you feel there is too much code, start by the
This_Document class module.

I have seen this problem many times, and always have been able to correct
the situation. Usually, you want to pin down all the events that caused
changes to your template, thus prompting Word to ask if you want to save it
or not.
Once you have pinpointed the said events, then you either save the template
right after the event has occurred or you make Word believe it has been
saved.

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


cw said:
I have created a template and when i create a document based on the
template and then save the document i am asked if i want to save the
template. Then when i close the document i am asked if i want to save
changes to xxxxx.dot.
Can i get rid of either of these or both?
I have seen some code in an earlier answer (Jean-Guy Marcil) and tried
that but it doesn't have any effect.
 
The reason you are being asked these questions is that you are, somehow,
making changes in the templates involved. If you eliminate the changes you
will eliminate the questions. The following are common changes made to
templates from within documents:
1) Change the interface - toolbars - keyboard shortcuts - menus
2) Change styles and save changes to template
3) Change AutoText
4) Record macros

Any of these going on, either directly, or through code in your templates?

Is xxxxx.dot normal.dot?

Which version of Word are you using?
--

Charles Kenyon

See the MVP FAQ: <URL: http://www.mvps.org/word/> which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.

cw said:
I have created a template and when i create a document based on the
template and then save the document i am asked if i want to save the
template. Then when i close the document i am asked if i want to save
changes to xxxxx.dot.
Can i get rid of either of these or both?
I have seen some code in an earlier answer (Jean-Guy Marcil) and tried
that but it doesn't have any effect.
 
Private Sub Document_new(

Dim temp As Intege
Dim newButton As CommandBarButto

temp = MsgBox("Would you like to activate the Ciba Issue Table Tool?" & Chr(13) & "By clicking 'Yes' the tool will be added to your Tools menu." & Chr(13) & "For support please see the 'About' section.", vbQuestion + vbYesNo + vbDefaultButton2, "Ciba"
If temp = vbYes The

'Setting Popup Menu in default Tools men

Set newItem = CommandBars("Tools").Controls.Add(Type:=msoControlPopup, Before:=1, Temporary:=True
With newIte
.BeginGroup = Tru
.Caption = "Ciba
.Tag = "Ciba
End Wit

'Adding ControlButtons to new Popu

Set newButton = newItem.Controls.Add(Type:=msoControlButton, Temporary:=True
With newButto
.Caption = "Add New Issue
.FaceId =
.OnAction = "NewIssue
End Wit



Set newButton = newItem.Controls.Add(Type:=msoControlButton, Temporary:=True
With newButto
.Caption = "Update Issue Table
.FaceId =
.OnAction = "Summary
End Wit


Set newButton = newItem.Controls.Add(Type:=msoControlButton, Temporary:=True
With newButto
.Caption = "Update TOC
.FaceId =
.OnAction = "UpdateTOC
End Wit

Set newButton = newItem.Controls.Add(Type:=msoControlButton, Temporary:=True
With newButto
.BeginGroup = Tru
.Caption = "About
.FaceId =
.OnAction = "About
End Wit

End I

End Su

Private Sub Document_Close(
ActiveDocument.AttachedTemplate.Saved = Tru

Dim synCtrl As CommandBarContro

'Deleting popup in container applicatio

Set synCtrl = CommandBars("Tools").FindControl(Type:=msoControlPopup, Tag:="Ciba"
On Error GoTo NoPopu
synCtrl.Delet

NoPopup
En

End Su

Private Sub Document_Open(

Dim temp As Intege
Dim newButton As CommandBarButto

temp = MsgBox("Would you like to activate the Ciba Issue Table Tool?" & Chr(13) & "By clicking 'Yes' the tool will be added to your Tools menu." & Chr(13) & "For support please see the 'About' section.", vbQuestion + vbYesNo + vbDefaultButton2, "Ciba"
If temp = vbYes The

'Setting Popup Menu in default Tools men

Set newItem = CommandBars("Tools").Controls.Add(Type:=msoControlPopup, Before:=1, Temporary:=True
With newIte
.BeginGroup = Tru
.Caption = "Ciba
.Tag = "Ciba
End Wit

'Adding ControlButtons to new Popu

Set newButton = newItem.Controls.Add(Type:=msoControlButton, Temporary:=True
With newButto
.Caption = "Add New Issue
.FaceId =
.OnAction = "NewIssue
End Wit



Set newButton = newItem.Controls.Add(Type:=msoControlButton, Temporary:=True
With newButto
.Caption = "Update Issue Table
.FaceId =
.OnAction = "Summary
End Wit


Set newButton = newItem.Controls.Add(Type:=msoControlButton, Temporary:=True
With newButto
.Caption = "Update TOC
.FaceId =
.OnAction = "UpdateTOC
End Wit

Set newButton = newItem.Controls.Add(Type:=msoControlButton, Temporary:=True
With newButto
.BeginGroup = Tru
.Caption = "About
.FaceId =
.OnAction = "About
End Wit

End I

End Su

----- Jean-Guy Marcil wrote: ----

Hi cw

I do not remember the post you are referring to... I browse through a fe
NG... ;-

If you have done so already, could you be so kind as to post all the cod
contained in your template. If you feel there is too much code, start by th
This_Document class module

I have seen this problem many times, and always have been able to correc
the situation. Usually, you want to pin down all the events that cause
changes to your template, thus prompting Word to ask if you want to save i
or not
Once you have pinpointed the said events, then you either save the templat
right after the event has occurred or you make Word believe it has bee
saved.

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


cw said:
I have created a template and when i create a document based on the
template and then save the document i am asked if i want to save the
template. Then when i close the document i am asked if i want to save
changes to xxxxx.dot.
Can i get rid of either of these or both?
I have seen some code in an earlier answer (Jean-Guy Marcil) and tried
that but it doesn't have any effect.
 
Hi DJW

There's a couple of problems unless you've not posted all of your code.
You're doing the same things in both the Document_new and Document_Open events
so why not put that code into a subroutine rather than duplicate the code?

In your code you are not setting the CustomizationContext so the toolbar changes
are actually being made to the Normal template (Normal.dot). You need to set
the CustomizationContext to your template and then reassign it to Normal.dot
when you've finished your updates.

The second problem (the one that's causing the "do you want to save..." prompts
to appear) is that you're setting the Templates saved property but then dirtying
the template by deleting the CommandBarControl!

This is what the revised procedures should look like:

Private Sub Document_new()
Dim newItem As Office.CommandBarControl
Dim temp As Integer
Dim newButton As CommandBarButton


temp = MsgBox("Would you like to activate the Ciba Issue Table Tool?" &
Chr(13) & "By clicking 'Yes' the tool will be added to your Tools menu." &
Chr(13) & "For support please see the 'About' section.", vbQuestion + vbYesNo +
vbDefaultButton2, "Ciba")
If temp = vbYes Then

CustomizationContext = ThisDocument

'Setting Popup Menu in default Tools menu

Set newItem = CommandBars("Tools").Controls.Add(Type:=msoControlPopup,
Before:=1, Temporary:=True)
With newItem
.BeginGroup = True
.Caption = "Ciba"
.Tag = "Ciba"
End With

'Adding ControlButtons to new Popup

Set newButton = newItem.Controls.Add(Type:=msoControlButton,
Temporary:=True)
With newButton
.Caption = "Add New Issue"
.FaceId = 0
.OnAction = "NewIssue"
End With

Set newButton = newItem.Controls.Add(Type:=msoControlButton,
Temporary:=True)
With newButton
.Caption = "Update Issue Table"
.FaceId = 0
.OnAction = "Summary"
End With


Set newButton = newItem.Controls.Add(Type:=msoControlButton,
Temporary:=True)
With newButton
.Caption = "Update TOC"
.FaceId = 0
.OnAction = "UpdateTOC"
End With

Set newButton = newItem.Controls.Add(Type:=msoControlButton,
Temporary:=True)
With newButton
.BeginGroup = True
.Caption = "About"
.FaceId = 0
.OnAction = "About"
End With

CustomizationContext = NormalTemplate
End If

End Sub


LIkewise Document_Close needs modifying:


Private Sub Document_Close()
Dim synCtrl As CommandBarControl

CustomizationContext = ThisDocument

'Deleting popup in container application
Set synCtrl = CommandBars("Tools").FindControl(Type:=msoControlPopup,
Tag:="Ciba")
On Error GoTo NoPopup
synCtrl.Delete

NoPopup:
ActiveDocument.AttachedTemplate.Saved = True
CustomizationContext = NormalTemplate
End Sub


HTH + Cheers - Peter
 
Back
Top