Event - Document Edited

坚强是说给别人听的谎言 提交于 2019-12-01 07:54:25

问题


Is there an event for when a document is edited? If not, does anyone know where I could find a list of the available VBA events?


回答1:


Here are the events for the document object:

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. 

There are also Auto Macros:

AutoNew, AutoOpen, AutoExec, AutoExit




回答2:


The command is WindowSelectionChange




回答3:


To intercept any Word command, you can:

1.

Press Alt+ F8 to bring up the Macros dialog and where it says “Macros in”, select “Word Commands”.

2.

Find and select one of the commands you want to intercept – for instance, to intercept the Print commands you need to find FilePrint and FilePrintDefault. To intercept the Save commands you need to find FileSave, FileSaveAs and FileSaveAll

3.

Where it says “Macros in”, select the template you want to store the macro in, and click “Create”.

4.

The code needed to execute the command will be written for you; just add your own code.




回答4:


You may try autohotkey to listen the keypress event,look at my code:

Capturing keydown event of MS Word



来源:https://stackoverflow.com/questions/269252/event-document-edited

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!