View Single Post
  #20   Report Post  
Posted to microsoft.public.word.docmanagement
jezzica85
 
Posts: n/a
Default Highlighting specific words

One more thing, I went in and the VBA editor said the file was unviewable.
Did I do something wrong?

"Greg Maxey" wrote:

Ok,

Part of the problem is that you said you wanted to "highlight" text not
"change the color." The macro does not have a UI feature to change font
color (I might add it). However the code can easily be adapted to change
font color or practically anything else.

Open the template file and the press ALT+F11 to open the VB editor. If not
displayed, press CTRL+R to open the Project Explorer. You will see a
project named "VBA Find and Replace" If not explanded, expand it an you
will see a folder named Forms. Double click the form named UserInterface.
Either the form or the form code will appear. If it is the form the right
click UserInterface again and select few code. Now using the right hand
scrool bar, scrool down in the code until you come to the last Function
named:

Public Function SrchAndReplaceInStory ....

You are going to need to add a line of code.

The twelfth line down reads:
..Replacement.Text = ListArray(i, 2)

immediately after that line add this line:
..Replacement.Font.Color = wdColorRed

Using the file menu in the VB editor now save the project.

Ok, now for your error.

I just process a collection of forty differenct words and phrases with no
errors. Yes, 7000 may be too much for one bite and you might have to do it
in segments, however I don't know why you are having errors at 15. Can you
give me an example of the list of words that you are using?




--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


jezzica85 wrote:
OK, let's give it a shot. I made the word list in the predefined
words, with the find and replace columns identical except for the
replace column being red instead of black. What I want to do is
whenever a word in the find column appears in my document, I want to
replace it with the red version. The macro sort of seems to run if I
have a very small list of words, say 8 or 10, but it doesn't replace
with the red, it looks like it replaces with the same word, same
formatting, when I need the same word with the new formatting. If I
entered in anything more than 15 words, it would tell me that the
string parameter is too long. I've tried it so far in the predefined
list setting and the quicklist setting, and both of them do that.
Maybe 7000 words is just too long for the macro? It's probably some
small thing I'm doing wrong.

"Greg Maxey" wrote:

jezzica,
While I was napping John replied to your last post superbly ;-). We
need to establish exactly what it is that you are trying to do and
where in that process the macro falls short.

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

"jezzica85" wrote in message
...
Thanks for trying Greg, I redownloaded the macro and it still won't
work for
me. Maybe it's my computer.

"Greg Maxey" wrote:

That is odd. I just downloaded the template and gave it a try. I
typed: "One two three four five" in the document and then used the
"a Quicklist I
create now" option. I typed "One two three four five" in the Find
column and the Replace column, saved the file and close it. Then
checked "Highlight" and "Go".

Result: One two three four five was highlighted in the document.



--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

"jezzica85" wrote in message
...
As a matter of fact, I didn't ignore your suggestion, Greg. It
was the first
thing I tried, and it didn't work. The find and replace didn't
replace anything.

"Greg Maxey" wrote:

I have offered you a possible solution that so far you have
choosen to ignore. Provided you can define your list of 7000
words in a simple table
with the same 7000 words listed as both the find and replace
word as then
the Add-in will do it in fairly short order.

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


jezzica85 wrote:
I probably should have said this before (sheepish shrug) but I
have almost 7000 words to go through. Is there a way to do
them with AutoCorrect without needing to enter each one
individually?

"Suzanne S. Barnhill" wrote:

I don't think AutoCorrect will really do what you're thinking
about,
but see http://word.mvps.org/faqs/customization/AutoCorrect.htm

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

"jezzica85" wrote in
message
...
Thanks John, but I can't seem to find this. Is it only in
certain versions of Word? I have XP.

"John McGhie [MVP - Word and Word Macinto" wrote:

Hi Jezzica:

Yes, you can do this with AutoCorrect.

Study the topic "Create an AutoCorrect entry to store and
automatically insert text and graphics" in the Help.

You need to enter the words you want to search for in your
AutoCorrect list, and replace them with the same word
highlighted.
Make sure you choose the "Formatted" options or the
highlighting won't come in.

Forget macros for this task. You would need to be a
seriously good
programmer to make a macro to do this. Ask Jezebel if s/he
will send you one, because I have never seen a macro that
could do this
with acceptable performance :-)

Hope this helps

On 1/4/06 2:08 PM, in article
,
"jezzica85" wrote:

That would be perfect! I have no idea how to write or use
macros, though, could you possibly direct me to one and
give me pointers on how to use it? Thanks!

"Jezebel" wrote:

You can't do *anything* automatically while you type, other
than
autocorrect which isn't going to help you here.

You could write a macro that reads words from a file or
table, searches for them in another document, and formats
them in a special way. Would that help?




"jezzica85" wrote in
message
...
Hi all, does anyone know, if you have a file of words you
want to keep track
of, if there's a way to automatically highlight those
words in another file,
or to put those words in a table in the other file, then
automatically highlight them as they're typed or they
already appear in the document? Thanks!




--

Please reply to the newsgroup to maintain the thread.
Please do not email me unless I ask you to.

John McGhie
Microsoft MVP, Word and Word for Macintosh. Consultant
Technical Writer Sydney, Australia +61 (0) 4 1209 1410