Hello Johnbibby,
I have attached a Visual Basic macro that can be added to a document
(or to your "Normal" file) which reformats the document as you asked.
To use the macro, do the following steps:
[0] Start MS Word (an empty file is fine). Depending on the version of
Word, you may also have to change the "security" (or "Macro Virus
Protection") preferences so macros can run - tell me the specific
version of Word in a request for clarification if you have problems
running the macro.
[1] Use the menu
Tools -> Macro -> Visual Basic Editor
At this point, Visual Basic should start. In the upper left is a
"Project" window listing the open files.
[2] Select one of the files (Normal.Dot refers to a file always opened
by MS Word) and use the menu
Insert -> Module
Another window should open.
[3] Copy / paste the macro from the answer into this module (or code) window.
[4] Make any changes you find necessary (explained below).
[5] Close & return to MS Word (another menu selection - usually under "File").
At this point, using the menu
Tools -> Macro -> Macros...
will bring up a list of the available macros. "jb" should be listed.
Selecting that macro & run will cause the macro to execute and should
do all the changes you requested.
If you put the macro into Normal.DOT, Word may prompt you to save
changes - say yes (or OK) to save the macro. If you put the macro into
an ordinary file, it will be saved with that file.
There are a few locations you may wish to change the macro:
o The strings A$ and B$ which represent the start / end phrases of the search.
o The formatting near the end - currently it makes the text bold and blue.
I added some comments at these locations to remind you of these
changes and describing some of the alternatives that are available.
Please make a request for clarification if any part of the answer is
unclear or you have any difficulty using the macro with your files.
Good luck with your work.
--Maniac
Sub jb()
'
' Macro written by Maniac on May 16, 2006
' Reformats text between two strings
'
' Specify search phrases (start / end)
A$ = "abc"
B$ = "def"
' Start at the beginning and reset all
' search formatting options
ActiveDocument.Range(0).Select
Selection.Find.ClearFormatting
' Loop repeats until first phrase not found
While Selection.Find.Execute(A$)
StartReformat = Selection.End
Selection.MoveRight
Selection.Find.Execute (B$)
StopReformat = Selection.Start
Selection.MoveRight
' Add formatting to the following section
' Options include:
' .Bold, .Italic, .Underline, .StrikeThrough (true / false)
' .Size = font size
' .Font.Color = wdColorGreen (Red, Blue, etc... see help)
With ActiveDocument.Range(StartReformat, StopReformat)
.Bold = True
.Font.Color = wdColorBlue
End With
Wend
End Sub |