View Single Post
  #20   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Use DocVariable field to initiative numbering?


"mystyle" with another style, such as "stylex"? In other words, how do
I swap styles? (I thought it would be something like
myRange.InsertStyleRef ("stylex") but it didn't work.)


What you probably need is
myRange.Style = "stylex"

However, it depends partly on whether you want to apply a style to the
entire paragraph or the text in the range (and/or whether you are applying a
paragraph style or a character style)

Peter Jamieson

"Tom" wrote in message
ps.com...
Peter,

The macro code you wrote works perfectly! Thanks. It's really
impressive to see all of these macros in action. I'm planning to put
them all together into a template that technical writers can easily use
to convert RoboHelp generated source material into a Word document.

I have a related question. In the following code, how would I change
the line myRange.InsertCaption Label:="Figure" to replace the
"mystyle" with another style, such as "stylex"? In other words, how do
I swap styles? (I thought it would be something like
myRange.InsertStyleRef ("stylex") but it didn't work.)

Sub ScratchMacro()
Dim myRange As Range
Set myRange = ActiveDocument.Range
With myRange.Find
.Style = ActiveDocument.Styles("mystyle")
.MatchWholeWord = True
While .Execute
myRange.Delete
myRange.InsertCaption Label:="Figure"
Wend
End With
End Sub


Also, let's say I have 15 style swaps that I want to make with one
macro. I'm assuming that i just remove the words "End Sub" from the
end, and add the additional macro code, but without the additional
macro's name (e.g., Sub ScratchMacro())?

Thanks.