Reply
 
Thread Tools Display Modes
  #1   Report Post  
AA2e72E
 
Posts: n/a
Default 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   Report Post  
Daiya Mitchell
 
Posts: n/a
Default

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   Report Post  
AA2e72E
 
Posts: n/a
Default

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   Report Post  
Daiya Mitchell
 
Posts: n/a
Default

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   Report Post  
Klaus Linke
 
Posts: n/a
Default

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

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro Button Won't Stay on Toolbar caleb Microsoft Word Help 2 June 14th 05 11:59 PM
How do you end or "turn off" a character style while entering text Larry Root Microsoft Word Help 3 April 25th 05 03:29 PM
Word 2003: Can one disable table styles? [email protected] Tables 5 April 10th 05 10:02 AM
Font properties of table styles versus paragraph styles Bob S Tables 3 February 8th 05 01:13 PM
2000 to 2002 macro and "Could not open macro storage" Art Farrell Mailmerge 1 December 6th 04 12:40 PM


All times are GMT +1. The time now is 09:55 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"