Good evening,
In the AutoNew() procedure of a dotm template, I change a Word keyboard shortcut by calling a macro, by the following lines:
CustomizationContext = ActiveDocument.AttachedTemplate ' (it's about the same problem with Application.NormalTemplate)
ActiveDocument.AttachedTemplate.Saved = True
KeyBindings.Add KeyCategory:=wdKeyCategoryMacro, Command:="M1_TC.M1_TC_Ctrl_S", KeyCode:=BuildKeyCode(wdKeyControl, wdKeyS)
In fact, I want the user to save the current document through my save procedure and not through the one proposed by default by Word.
The shortcut works well, but as soon as the user exits Word, the application asks him to save the changes made to the template, which I do not want. I want the user to exit Word without having this message, and that no modification is saved neither in the custom dotm (ActiveDocument.AttachedTemplate), nor in the Normal.dotm Template (Application.NormalTemplate).
For that, in the AutoClose() procedure I tried a lot of things without finding a real success. Here are the lines I tried a bit in all directions, commented or not :
CustomizationContext = NormalTemplateKeyBindings.ClearAll
Application.NormalTemplate.Saved = True
ActiveDocument.Saved = True
KeyBindings.ClearAll
ThisDocument.Close (wdDoNotSaveChanges)
Application.ActiveDocument.Close (wdDoNotSaveChanges)
Application.NormalTemplate.AutoSaveOn = False
Has anyone encountered this difficulty and/or could help me?
Sincerely,
David
Translated with
www.DeepL.com/Translator (free version)