Y a-t-il un événement pour le moment où un document est modifié? Sinon, quelqu'un sait-il où je pourrais trouver une liste des événements VBA disponibles?Evénement - Document modifié
Répondre
Voici les événements pour l'objet document:
http://msdn.microsoft.com/en-us/library/aa140279(office.10).aspx
Events
DocumentBeforeClose : Immediately before any open document closes.
DocumentBeforePrint : Before any open document is printed.
DocumentBeforeSave : Before any open document is saved.
DocumentChange : A new document is created, when an existing document is opened, or when another document is made the active document.
DocumentOpen : A document is opened.
EPostageInsert : A user inserts electronic postage into a document.
EPostagePropertyDialog : A user clicks the E-postage Properties (Labels and Envelopes dialog box) button or Print Electronic Postage toolbar button. This event allows a third-party software application to intercept and show their properties dialog box.
MailMergeAfterMerge : After all records in a mail merge have merged successfully.
MailMergeAfterRecordMerge : After each record in the data source successfully merges in a mail merge.
MailMergeBeforeMerge : A merge is executed before any records merge.
MailMergeBeforeRecordMerge : As a merge is executed for the individual records in a merge.
MailMergeDataSourceLoad : The data source is loaded for a mail merge.
MailMergeDataSourceValidate : A user performs address verification by clicking Validate in the Mail Merge Recipients dialog box.
MailMergeWizardSendToCustom : The custom button is clicked on step six of the Mail Merge Wizard.
MailMergeWizardStateChange : A user changes from a specified step to a specified step in the Mail Merge Wizard.
NewDocument : A new document is created.
Quit : The user quits Word.
WindowActivate : Any document window is activated.
WindowBeforeDoubleClick : The editing area of a document window is double-clicked, before the default double-click action.
WindowBeforeRightClick : The editing area of a document window is right-clicked, before the default right-click action.
WindowDeactivate : Any document window is deactivated.
WindowSelectionChange : The selection changes in the active document window.
WindowSize : The application window is resized or moved.
Il y a aussi des macros Auto:
AutoNew, AutoOpen, AutoExec, AutoExit
Pour intercepter toute commande Word, vous pouvez:
1.
Appuyez sur Alt + F8 pour faire apparaître la boîte de dialogue de macros et où il est dit « dans les macros », sélectionnez « commandes Word ».
2.
Recherchez et sélectionnez l'une des commandes que vous voulez intercepter - par exemple, pour intercepter l'impression que vous devez trouver les commandes FilePrint et FilePrintDefault. Pour intercepter les commandes d'enregistrement vous devez trouver FileSave, FileSaveAs et FileSaveAll
3.
Où il est dit « dans les macros », sélectionnez le modèle que vous souhaitez stocker la macro dans, puis cliquez sur « Créer ».
4.
Le code nécessaire pour exécuter la commande sera écrite pour vous; il suffit d'ajouter votre propre code.
La commande est WindowSelectionChange
Vous pouvez essayer autohotkey d'écouter l'événement KeyPress, regardez mon code: