If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#21
|
|||
|
|||
Macro for highlighting
Anthony,
I know that your can use your current macros but, anyway, I will try to explain a little more ;-) - not least because it could make your work even easier. After your latest explanation I am sure that what both Tony and I started to explain is the only thing you need - a single line of code in the macro (no SendKeys) - and you can have a macro for each highlight color. The only passage in your explanation that confuses me a little is "(usually without selecting it first)" - I think you select the text you want to highlight or?... I (and a lot of people I have created macros for) do what you do several times every day, i.e. apply different highlight colors to text and for that purpose I have created a series of macros like the ones below - one per used color. In order to make it fast and easy to apply the different colors, I have assigned shortcuts to the individual highlight macros (they have been added to a custom toolbar as well - with colored icons as you describe). I have used these shortcuts that do not conflict with built-in shortcuts and that are easy to remember: Alt+Ctrl+Y for Yellow (wdYellow) Alt+Ctrl+P for Pink (wdPink) Alt+Ctrl+G for Green (wdBrightGreen) Alt+Ctrl+B for Blue (wdTurquoise) Alt+Ctrl+R for Red (wdRed) Alt+Ctrl+ for no highlight (wdNoHighlight) - i.e. the macro that removes the highlight The _important_ thing is that when you apply the highlight via a _macro_, you can do that _without_ first changing the highlight color of the highlight icon. You simply do not need "Selection.Range.HighlightColorIndex = wdRed". I know that this line is the only one you get if you record a macro but, as Tony said, the macro recorder is not perfect - that macro does not apply any highlight when executed afterwards. For that purpose you need "Selection.Range.HighlightColorIndex = [your color]". So back to the start: The following macro will change the highlight color of the selection to red _regardless_ of what color is currently shown in the highlight icon (i.e. the macro determines the color, not the highlight icon): Sub HighLight_Red() Selection.Range.HighlightColorIndex = wdRed End Sub Correspondingly, the following macro will change the highlight color of the selection to yellow _regardless_ of what color is currently shown in the highlight icon: Sub HighLight_Yellow() Selection.Range.HighlightColorIndex = wdYellow End Sub The following macro will _remove_ any highlight from the selection _regardless_ of what color is currently shown in the highlight icon: Sub HighLight_Red() Selection.Range.HighlightColorIndex = wdNoHighlight End Sub This way you can create a corresponding macro for each of the highlight colors you want to use. And if you assign shortcuts, you can apply any of the highlight colors or remove the highlight simply by pressing the shortcut (that is what I always do). You never need to care about which color is selected in the highlight icon. Hope this helps. -- Regards Lene Fredborg DocTools - Denmark www.thedoctools.com Document automation - add-ins, macros and templates for Microsoft Word "Anthony Giorgianni" wrote: Thanks everyone for your help. I think I'll simply to stick with using the sendkeys command. That's a neat macro Lene but doesn't seem to do what I'm looking for. I think I'm probably not explaining it right. All I want to be able to do is simply turn on highlighting with a certain color with one click, avoiding having to go up to the highlighting menu item, select the color and turn it on. The reason is that, as a journalist, many times I'm reading a document and want to highlight items for different importance - green = interesting but not critical, yellow = pretty important, red = information that I must use. So when I see something pretty important, I want to turn on yellow highlighting with one click of a toolbar icon. Then I highlight that (usually without selecting it first) Later I might see something that's critical, so I want to turn on red highlighting with one click. This does that exactly Options.DefaultHighlightColorIndex = wdYellow REM: Selects the highlighting color yellow SendKeys "{F5}" REM Turns on highlighting, where Word has been set to associate F5 with turning on highlighting. Tony suggested that using sendkeys isn't the best way to do this. It certainly doesn't make the macro portable if I want to transfer it to another machine without having to set F5 (as I found out when I tried to transfer it from my home to my work machine and forgot about setting F5 to turn on highlighting.) So I was curious if there was another way to do it. But it's no big deal. It works fine. By the way, to make it really easy, I created a "highlighting" toolbar with icons that are simply colored squares, each assigned to a different color macro and one assigned to "no color" for clearing. Thanks again. Regards Anthony Giorgianni For everyone's benefit, please reply to the group. "Lene Fredborg" wrote in message ... Greg, About changing the previous highlighting too: after reading the description again now, I am sure you are right - however, I did not read it that way first. About the insertion point being in a word: you are right, if the option "When selecting, automatically select entire word" in Tools Options Edit tab is turned on, the code line "Selection.Range.HighlightColorIndex = wdRed" would highlight that word. I should have taken this into consideration by making a check in the code as you did in your version - unfortunately, I failed to notice this because I do not have that option turned on. -- Regards Lene Fredborg DocTools - Denmark www.thedoctools.com Document automation - add-ins, macros and templates for Microsoft Word |
#22
|
|||
|
|||
Macro for highlighting
Hey Lene
Thanks again. I'm sorry I'm not being clear . Or maybe I'm being dense :O). When I say I don't want to select the text first, I mean that: I'm simply reading through a document and want to turn on the highlighting tool - the thing that changes the cursor into a virtual highlighting pen that you swipe across any text to highlight. This avoids having to actually select the text at all. So the combined function is 1) set the desired highlighting color 2) turn on the highlighting tool. So the macro would be 1) Select the highlight color (which we all know how to do) 2) Turn on the highlighting tool to transform the cursor into a highlighting pen (which is the part I can't figure out how to do as part of the macro without sendkeys) Oddly, if a record a macro, I get the first step. But when I click on the highlighting box to actually turn on the highlighting tool, that action doesn't get recorded in the VB code. See what I mean? Regards, Anthony Giorgianni For everyone's benefit, please reply to the group. "Lene Fredborg" wrote in message ... Anthony, I know that your can use your current macros but, anyway, I will try to explain a little more ;-) - not least because it could make your work even easier. After your latest explanation I am sure that what both Tony and I started to explain is the only thing you need - a single line of code in the macro (no SendKeys) - and you can have a macro for each highlight color. The only passage in your explanation that confuses me a little is "(usually without selecting it first)" - I think you select the text you want to highlight or?... I (and a lot of people I have created macros for) do what you do several times every day, i.e. apply different highlight colors to text and for that purpose I have created a series of macros like the ones below - one per used color. In order to make it fast and easy to apply the different colors, I have assigned shortcuts to the individual highlight macros (they have been added to a custom toolbar as well - with colored icons as you describe). I have used these shortcuts that do not conflict with built-in shortcuts and that are easy to remember: Alt+Ctrl+Y for Yellow (wdYellow) Alt+Ctrl+P for Pink (wdPink) Alt+Ctrl+G for Green (wdBrightGreen) Alt+Ctrl+B for Blue (wdTurquoise) Alt+Ctrl+R for Red (wdRed) Alt+Ctrl+ for no highlight (wdNoHighlight) - i.e. the macro that removes the highlight The _important_ thing is that when you apply the highlight via a _macro_, you can do that _without_ first changing the highlight color of the highlight icon. You simply do not need "Selection.Range.HighlightColorIndex = wdRed". I know that this line is the only one you get if you record a macro but, as Tony said, the macro recorder is not perfect - that macro does not apply any highlight when executed afterwards. For that purpose you need "Selection.Range.HighlightColorIndex = [your color]". So back to the start: The following macro will change the highlight color of the selection to red _regardless_ of what color is currently shown in the highlight icon (i.e. the macro determines the color, not the highlight icon): Sub HighLight_Red() Selection.Range.HighlightColorIndex = wdRed End Sub Correspondingly, the following macro will change the highlight color of the selection to yellow _regardless_ of what color is currently shown in the highlight icon: Sub HighLight_Yellow() Selection.Range.HighlightColorIndex = wdYellow End Sub The following macro will _remove_ any highlight from the selection _regardless_ of what color is currently shown in the highlight icon: Sub HighLight_Red() Selection.Range.HighlightColorIndex = wdNoHighlight End Sub This way you can create a corresponding macro for each of the highlight colors you want to use. And if you assign shortcuts, you can apply any of the highlight colors or remove the highlight simply by pressing the shortcut (that is what I always do). You never need to care about which color is selected in the highlight icon. Hope this helps. -- Regards Lene Fredborg DocTools - Denmark www.thedoctools.com Document automation - add-ins, macros and templates for Microsoft Word "Anthony Giorgianni" wrote: Thanks everyone for your help. I think I'll simply to stick with using the sendkeys command. That's a neat macro Lene but doesn't seem to do what I'm looking for. I think I'm probably not explaining it right. All I want to be able to do is simply turn on highlighting with a certain color with one click, avoiding having to go up to the highlighting menu item, select the color and turn it on. The reason is that, as a journalist, many times I'm reading a document and want to highlight items for different importance - green = interesting but not critical, yellow = pretty important, red = information that I must use. So when I see something pretty important, I want to turn on yellow highlighting with one click of a toolbar icon. Then I highlight that (usually without selecting it first) Later I might see something that's critical, so I want to turn on red highlighting with one click. This does that exactly Options.DefaultHighlightColorIndex = wdYellow REM: Selects the highlighting color yellow SendKeys "{F5}" REM Turns on highlighting, where Word has been set to associate F5 with turning on highlighting. Tony suggested that using sendkeys isn't the best way to do this. It certainly doesn't make the macro portable if I want to transfer it to another machine without having to set F5 (as I found out when I tried to transfer it from my home to my work machine and forgot about setting F5 to turn on highlighting.) So I was curious if there was another way to do it. But it's no big deal. It works fine. By the way, to make it really easy, I created a "highlighting" toolbar with icons that are simply colored squares, each assigned to a different color macro and one assigned to "no color" for clearing. Thanks again. Regards Anthony Giorgianni For everyone's benefit, please reply to the group. "Lene Fredborg" wrote in message ... Greg, About changing the previous highlighting too: after reading the description again now, I am sure you are right - however, I did not read it that way first. About the insertion point being in a word: you are right, if the option "When selecting, automatically select entire word" in Tools Options Edit tab is turned on, the code line "Selection.Range.HighlightColorIndex = wdRed" would highlight that word. I should have taken this into consideration by making a check in the code as you did in your version - unfortunately, I failed to notice this because I do not have that option turned on. -- Regards Lene Fredborg DocTools - Denmark www.thedoctools.com Document automation - add-ins, macros and templates for Microsoft Word |
#23
|
|||
|
|||
Macro for highlighting
Yes, now - finally - I see what you mean :-)
And now I also understand what you meant by "usually without selecting it first". Happy highlighting! --- Regards Lene Fredborg DocTools - Denmark www.thedoctools.com Document automation - add-ins, macros and templates for Microsoft Word "Anthony Giorgianni" wrote: Hey Lene Thanks again. I'm sorry I'm not being clear . Or maybe I'm being dense :O). When I say I don't want to select the text first, I mean that: I'm simply reading through a document and want to turn on the highlighting tool - the thing that changes the cursor into a virtual highlighting pen that you swipe across any text to highlight. This avoids having to actually select the text at all. So the combined function is 1) set the desired highlighting color 2) turn on the highlighting tool. So the macro would be 1) Select the highlight color (which we all know how to do) 2) Turn on the highlighting tool to transform the cursor into a highlighting pen (which is the part I can't figure out how to do as part of the macro without sendkeys) Oddly, if a record a macro, I get the first step. But when I click on the highlighting box to actually turn on the highlighting tool, that action doesn't get recorded in the VB code. See what I mean? Regards, Anthony Giorgianni For everyone's benefit, please reply to the group. "Lene Fredborg" wrote in message ... Anthony, I know that your can use your current macros but, anyway, I will try to explain a little more ;-) - not least because it could make your work even easier. After your latest explanation I am sure that what both Tony and I started to explain is the only thing you need - a single line of code in the macro (no SendKeys) - and you can have a macro for each highlight color. The only passage in your explanation that confuses me a little is "(usually without selecting it first)" - I think you select the text you want to highlight or?... I (and a lot of people I have created macros for) do what you do several times every day, i.e. apply different highlight colors to text and for that purpose I have created a series of macros like the ones below - one per used color. In order to make it fast and easy to apply the different colors, I have assigned shortcuts to the individual highlight macros (they have been added to a custom toolbar as well - with colored icons as you describe). I have used these shortcuts that do not conflict with built-in shortcuts and that are easy to remember: Alt+Ctrl+Y for Yellow (wdYellow) Alt+Ctrl+P for Pink (wdPink) Alt+Ctrl+G for Green (wdBrightGreen) Alt+Ctrl+B for Blue (wdTurquoise) Alt+Ctrl+R for Red (wdRed) Alt+Ctrl+ for no highlight (wdNoHighlight) - i.e. the macro that removes the highlight The _important_ thing is that when you apply the highlight via a _macro_, you can do that _without_ first changing the highlight color of the highlight icon. You simply do not need "Selection.Range.HighlightColorIndex = wdRed". I know that this line is the only one you get if you record a macro but, as Tony said, the macro recorder is not perfect - that macro does not apply any highlight when executed afterwards. For that purpose you need "Selection.Range.HighlightColorIndex = [your color]". So back to the start: The following macro will change the highlight color of the selection to red _regardless_ of what color is currently shown in the highlight icon (i.e. the macro determines the color, not the highlight icon): Sub HighLight_Red() Selection.Range.HighlightColorIndex = wdRed End Sub Correspondingly, the following macro will change the highlight color of the selection to yellow _regardless_ of what color is currently shown in the highlight icon: Sub HighLight_Yellow() Selection.Range.HighlightColorIndex = wdYellow End Sub The following macro will _remove_ any highlight from the selection _regardless_ of what color is currently shown in the highlight icon: Sub HighLight_Red() Selection.Range.HighlightColorIndex = wdNoHighlight End Sub This way you can create a corresponding macro for each of the highlight colors you want to use. And if you assign shortcuts, you can apply any of the highlight colors or remove the highlight simply by pressing the shortcut (that is what I always do). You never need to care about which color is selected in the highlight icon. Hope this helps. -- Regards Lene Fredborg DocTools - Denmark www.thedoctools.com Document automation - add-ins, macros and templates for Microsoft Word "Anthony Giorgianni" wrote: Thanks everyone for your help. I think I'll simply to stick with using the sendkeys command. That's a neat macro Lene but doesn't seem to do what I'm looking for. I think I'm probably not explaining it right. All I want to be able to do is simply turn on highlighting with a certain color with one click, avoiding having to go up to the highlighting menu item, select the color and turn it on. The reason is that, as a journalist, many times I'm reading a document and want to highlight items for different importance - green = interesting but not critical, yellow = pretty important, red = information that I must use. So when I see something pretty important, I want to turn on yellow highlighting with one click of a toolbar icon. Then I highlight that (usually without selecting it first) Later I might see something that's critical, so I want to turn on red highlighting with one click. This does that exactly Options.DefaultHighlightColorIndex = wdYellow REM: Selects the highlighting color yellow SendKeys "{F5}" REM Turns on highlighting, where Word has been set to associate F5 with turning on highlighting. Tony suggested that using sendkeys isn't the best way to do this. It certainly doesn't make the macro portable if I want to transfer it to another machine without having to set F5 (as I found out when I tried to transfer it from my home to my work machine and forgot about setting F5 to turn on highlighting.) So I was curious if there was another way to do it. But it's no big deal. It works fine. By the way, to make it really easy, I created a "highlighting" toolbar with icons that are simply colored squares, each assigned to a different color macro and one assigned to "no color" for clearing. Thanks again. Regards Anthony Giorgianni For everyone's benefit, please reply to the group. "Lene Fredborg" wrote in message ... Greg, About changing the previous highlighting too: after reading the description again now, I am sure you are right - however, I did not read it that way first. About the insertion point being in a word: you are right, if the option "When selecting, automatically select entire word" in Tools Options Edit tab is turned on, the code line "Selection.Range.HighlightColorIndex = wdRed" would highlight that word. I should have taken this into consideration by making a check in the code as you did in your version - unfortunately, I failed to notice this because I do not have that option turned on. -- Regards Lene Fredborg DocTools - Denmark www.thedoctools.com Document automation - add-ins, macros and templates for Microsoft Word |
#24
|
|||
|
|||
Macro for highlighting
Thanks again for all your help!!!!
Regards Anthony Giorgianni For everyone's benefit, please reply to the group. "Lene Fredborg" wrote in message ... Yes, now - finally - I see what you mean :-) And now I also understand what you meant by "usually without selecting it first". Happy highlighting! --- Regards Lene Fredborg DocTools - Denmark www.thedoctools.com Document automation - add-ins, macros and templates for Microsoft Word |
Thread Tools | |
Display Modes | |
|
|