Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-23-2023, 12:59 PM
Ddadoo57 Ddadoo57 is offline Problems with KeyBindings.Add when closing Word Windows 11 Problems with KeyBindings.Add when closing Word Office 2021
Advanced Beginner
Problems with KeyBindings.Add when closing Word
 
Join Date: Feb 2023
Posts: 73
Ddadoo57 is on a distinguished road
Default Problems with KeyBindings.Add when closing Word

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)
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems with KeyBindings.Add when closing Word Need Help With How To Use KeyBindings PosseJohn Word VBA 6 12-06-2013 02:23 PM
Closing Word files Humptydingo Word 5 09-07-2013 10:17 AM
Problems with KeyBindings.Add when closing Word KeyBindings in PowerPoint? tinfanide PowerPoint 1 03-16-2013 10:13 AM
Problems with KeyBindings.Add when closing Word Word crashes when closing mbjackson Word 1 02-06-2010 01:01 AM
Problems closing Word 2007 and editing .doc files sinjin Word 1 04-07-2009 09:09 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:05 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft