F
Fred Goldman
Ok, I just wrote my first code. I was wondering if anyone could tell me how
it could be written better and maybe help me on a few points.
Here's the code:
Set myCharStyle = ActiveDocument.Styles("Drop P'nim")
Set myPara = ActiveDocument.Styles("Body Text2")
Set myChar = ActiveDocument.Styles("Ha'aros")
Do
If Selection.Style = myPara Then
Selection.MoveRight Unit:=wdWord, Count:=1, Extend:=wdExtend
Selection.Style = myCharStyle
Selection.MoveDown Unit:=wdParagraph, Count:=1
Selection.HomeKey Unit:=wdLine
Else
Selection.MoveDown Unit:=wdParagraph, Count:=1
End If
Loop Until Selection.Style = myChar
What it does is find every style that I specify and tag the first word with
a character style. I couldn't find a way to tell the loop to exit when it
reaches then end of the document so what I did was tag the last paragrah as
myChar and set the loop to exit when it reaches the last paragraph.
Is there anyway I can improve this code? How would I set myPara to more than
one style?
Thanks in advance!
it could be written better and maybe help me on a few points.
Here's the code:
Set myCharStyle = ActiveDocument.Styles("Drop P'nim")
Set myPara = ActiveDocument.Styles("Body Text2")
Set myChar = ActiveDocument.Styles("Ha'aros")
Do
If Selection.Style = myPara Then
Selection.MoveRight Unit:=wdWord, Count:=1, Extend:=wdExtend
Selection.Style = myCharStyle
Selection.MoveDown Unit:=wdParagraph, Count:=1
Selection.HomeKey Unit:=wdLine
Else
Selection.MoveDown Unit:=wdParagraph, Count:=1
End If
Loop Until Selection.Style = myChar
What it does is find every style that I specify and tag the first word with
a character style. I couldn't find a way to tell the loop to exit when it
reaches then end of the document so what I did was tag the last paragrah as
myChar and set the loop to exit when it reaches the last paragraph.
Is there anyway I can improve this code? How would I set myPara to more than
one style?
Thanks in advance!