Home |
Search |
Today's Posts |
#1
|
|||
|
|||
Associate macro with Style
Is there a way of associating a macro with a particular style? The objective
is for the macro to run on the application of the style; the macro does such things as create an index entry, conditionally shade particular lines etc. |
#2
|
|||
|
|||
You'll get better answers about macros if you ask in a newsgroup with VBA or
Programming (plus Word) in the name. However, it sounds to me as though some process would have to constantly be checking whether a style had been applied to trigger the macro, and that sounds difficult and inefficient. Why not use a macro to apply the style instead? I.e., select text, call the macro, and it applies the style to selected text, and then does everything else you want. Note: It is possible to intercept Word's built-in commands. I.e., if you name a macro FilePrint, whenever someone clicks Print and calls the FilePrint command, your FilePrint macro will intercept it and run instead. (I may have the exact wording off there, but that's the concept). I have not a clue whether Styles can be intercepted like that. You can ask in the VBA group. On 9/8/05 7:48 AM, "AA2e72E" wrote: Is there a way of associating a macro with a particular style? The objective is for the macro to run on the application of the style; the macro does such things as create an index entry, conditionally shade particular lines etc. -- Daiya Mitchell, MVP Mac/Word Word FAQ: http://www.word.mvps.org/ MacWord Tips: http://www.word.mvps.org/MacWordNew/ What's an MVP? A volunteer! Read the FAQ: http://mvp.support.microsoft.com/ |
#3
|
|||
|
|||
Thanks Daiya.
I can run a macro to apply the style although it is not as intuitive as having the application of the style automatically running the macro. I might resort to creatng a toolbar with a button for the macro: that might be intuitive enough! "Daiya Mitchell" wrote: You'll get better answers about macros if you ask in a newsgroup with VBA or Programming (plus Word) in the name. However, it sounds to me as though some process would have to constantly be checking whether a style had been applied to trigger the macro, and that sounds difficult and inefficient. Why not use a macro to apply the style instead? I.e., select text, call the macro, and it applies the style to selected text, and then does everything else you want. Note: It is possible to intercept Word's built-in commands. I.e., if you name a macro FilePrint, whenever someone clicks Print and calls the FilePrint command, your FilePrint macro will intercept it and run instead. (I may have the exact wording off there, but that's the concept). I have not a clue whether Styles can be intercepted like that. You can ask in the VBA group. On 9/8/05 7:48 AM, "AA2e72E" wrote: Is there a way of associating a macro with a particular style? The objective is for the macro to run on the application of the style; the macro does such things as create an index entry, conditionally shade particular lines etc. -- Daiya Mitchell, MVP Mac/Word Word FAQ: http://www.word.mvps.org/ MacWord Tips: http://www.word.mvps.org/MacWordNew/ What's an MVP? A volunteer! Read the FAQ: http://mvp.support.microsoft.com/ |
#4
|
|||
|
|||
Well, ask in a VBA group if you can intercept Styles.
Do other people have to use this? If you created a custom style menu or toolbar with only the styles they were supposed to use, then you could switch in your macro and no one would be the wiser. But anybody who uses keyboard shortcuts would be annoyed. On 9/9/05 12:35 AM, "AA2e72E" wrote: Thanks Daiya. I can run a macro to apply the style although it is not as intuitive as having the application of the style automatically running the macro. I might resort to creatng a toolbar with a button for the macro: that might be intuitive enough! "Daiya Mitchell" wrote: You'll get better answers about macros if you ask in a newsgroup with VBA or Programming (plus Word) in the name. However, it sounds to me as though some process would have to constantly be checking whether a style had been applied to trigger the macro, and that sounds difficult and inefficient. Why not use a macro to apply the style instead? I.e., select text, call the macro, and it applies the style to selected text, and then does everything else you want. Note: It is possible to intercept Word's built-in commands. I.e., if you name a macro FilePrint, whenever someone clicks Print and calls the FilePrint command, your FilePrint macro will intercept it and run instead. (I may have the exact wording off there, but that's the concept). I have not a clue whether Styles can be intercepted like that. You can ask in the VBA group. On 9/8/05 7:48 AM, "AA2e72E" wrote: Is there a way of associating a macro with a particular style? The objective is for the macro to run on the application of the style; the macro does such things as create an index entry, conditionally shade particular lines etc. |
#5
|
|||
|
|||
The Style command, as other commands that take arguments (like the style
name in this case) can't be intercepted as far as I know. There are a handful of built-in commands that apply certain styles (NormalStyle, ApplyHeading1 ... ApplyHeading3, ApplyListBullet) that can be intercepted, but Word doesn't run these commands if you assign those styles from the style dropdown or from the task pane. The "styles and formatting" task pane is more or less inaccessible to VBA, so there's really no practical way to do your own stuff if a user applies some style... unfortunately. I might resort to creatng a toolbar with a button for the macro: that might be intuitive enough! Yes, and hope for the best that users will use it, instead of applying the style in some other way. If they are used to the task pane, that might prove difficult. It's a shame that Word got harder and harder to automate in recent versions. The task pane just made things worse. :-( Klaus "Daiya Mitchell" wrote: Well, ask in a VBA group if you can intercept Styles. Do other people have to use this? If you created a custom style menu or toolbar with only the styles they were supposed to use, then you could switch in your macro and no one would be the wiser. But anybody who uses keyboard shortcuts would be annoyed. On 9/9/05 12:35 AM, "AA2e72E" wrote: Thanks Daiya. I can run a macro to apply the style although it is not as intuitive as having the application of the style automatically running the macro. I might resort to creatng a toolbar with a button for the macro: that might be intuitive enough! "Daiya Mitchell" wrote: You'll get better answers about macros if you ask in a newsgroup with VBA or Programming (plus Word) in the name. However, it sounds to me as though some process would have to constantly be checking whether a style had been applied to trigger the macro, and that sounds difficult and inefficient. Why not use a macro to apply the style instead? I.e., select text, call the macro, and it applies the style to selected text, and then does everything else you want. Note: It is possible to intercept Word's built-in commands. I.e., if you name a macro FilePrint, whenever someone clicks Print and calls the FilePrint command, your FilePrint macro will intercept it and run instead. (I may have the exact wording off there, but that's the concept). I have not a clue whether Styles can be intercepted like that. You can ask in the VBA group. On 9/8/05 7:48 AM, "AA2e72E" wrote: Is there a way of associating a macro with a particular style? The objective is for the macro to run on the application of the style; the macro does such things as create an index entry, conditionally shade particular lines etc. |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro Button Won't Stay on Toolbar | Microsoft Word Help | |||
How do you end or "turn off" a character style while entering text | Microsoft Word Help | |||
Word 2003: Can one disable table styles? | Tables | |||
Font properties of table styles versus paragraph styles | Tables | |||
2000 to 2002 macro and "Could not open macro storage" | Mailmerge |