Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Intercepting commands in Word 2007

Status
Not open for further replies.

Nelviticus

Programmer
Sep 9, 2003
1,819
GB
We are in the process of upgrading from Office 2002 to Office 2007 and I am trying to get some of our old code to work with the new version.

In Office 2002 you could intercept Word commands by writing your own functions with the same name, so if you wrote a function called 'FileSaveAs' then anyone choosing 'Save As' from the 'File' menu would run your code instead of the built-in Word command.

Under Office 2007 these intercepts no longer work. I don't think the command names have changed because if you record a macro and go Office Button/Save As/Word Document it records it as ActiveDocument.SaveAs, which is exactly what Word 2002 used to do.

Does anyone know how to intercept commands in Word 2007?

Thanks

Nelviticus
 
Well I've solved half of the problem myself - you need to add intercepts to Word's new FileSave commands:

- FileSaveWordDocx
- FileSaveWordDotx
- FileSaveWord11
- FileSaveAsOtherFormats

However I cannot for the life of me find what the new version of ToolsUnProtectDocument is. On the 'Review' tab there is a 'Protect Document' button which calls up the 'Restrict Formatting and Editing' pane. Clicks on the 'Yes, Start Enforcing Protection' and 'Stop Protection' buttons get assigned to 'ActiveDocument.Protect' and 'ActiveDocument.UnProtect' by the macro recorder but I am unable to figure out what commands to intercept. I've tried ToolsProtectUnprotectDocument, UnProtect, ToolsProtect and lots of others.

This is the most important bit for us and I'd greatly appreciate any help!

Thanks

Nelviticus
 
I do not have 2007 - and will avoid that as long as I can - but have you tried the Object Browser in the VBE? It may help. But then I have no idea what they have done with VBA and 2007.

It has to be a method of some sort.

faq219-2884

Gerry
My paintings and sculpture
 
Hello fumei, apparently the answer is that it can't be done, and couldn't be done in Word 2003 either. You just can't use VBA to intercept anything that happens in a task pane.

VBA still exists in 2007. Good things: you can now scroll the editor window with the mouse wheel (yay!); bad things: the VBA help hasn't been updated and uses a new format which makes it very hard to use (although that probably came in with 2003).

Regards

Nelviticus
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top