vsto-newbie

Hi,
I need to write code that will fire events when the user switches paragraphs/sections and changes the font face/changes the style etc on a Word 2007 document. Any suggestions


Re: Visual Studio Tools for Office Word 2007: How to determine the paragraph ID/section ID/ font type at the current cursor location using VSTO 2005 SE

Cindy Meister

You can't get full control for this, Word simply does not expose these events.

If the user moves to a new paragraph or section using the mouse or arrow keys, then the WindowSelectionChange event will be fired. You can trap this and evaluate.

There is no event that will fire when formatting is changed. Best you could do here would be to provide your own interface for formatting (your own Ribbon). But you won't have control over the Minibar, and you won't be able to intercept keypresses (such as Ctrl+B to apply Bold). Conceivably, you could disable all the KeyBindings, but you'd certainly have to restore them afterwards.






Re: Visual Studio Tools for Office Word 2007: How to determine the paragraph ID/section ID/ font type at the current cursor location using VSTO 2005 SE

Martin Sawicki - MSFT

I could imagine writing code that handles the Application.WindowSelectionChange event and tries to be clever about counting the number of paragraph marks before and after the selection change to determine which paragraph has been exited/entered by the user. Similarly for sections. But this just a quick idea - maybe it'll spark some other ideas.

As for fonts, the closest you can get to that probably is to replace Word's entry points to the font UI with your own (on the ribbon and the menus). I don't know what hurdles you'd run into with this, but it may be something worth exploring, since in theroy at least, it feels like it might work.

Sorry I can't be of any more help here.