B
Benz
I'm trying to create a macro that will insert xml markup before and
after text containing certain styles. I don't have much experience
creating macros, but below is what I have so far for this macro. It
seems to work for all the A heads in my document except for the last
one.
Sub Macro3()
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
Do
Selection.Find.Style = ActiveDocument.Styles("A head")
With Selection.Find
.Text = ""
.Replacement.Text = "<ahead></ahead>"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.HomeKey Unit:=wdLine
Selection.TypeText Text:="<ahead>"
Selection.EndKey Unit:=wdLine
Selection.TypeText Text:="</ahead>"
Loop Until (Selection.End = ActiveDocument.Content.End)
End Sub
I'm sure there is a better way to add xml code to styled text in a
Word doc, but I'm not quite sure where to start. I thought using
macros might be the best solution for now. I work in academic
publishing and our manuscripts need to be marked up with xml for our
typesetters.
Thanks in advance for any help!
Bendte
after text containing certain styles. I don't have much experience
creating macros, but below is what I have so far for this macro. It
seems to work for all the A heads in my document except for the last
one.
Sub Macro3()
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
Do
Selection.Find.Style = ActiveDocument.Styles("A head")
With Selection.Find
.Text = ""
.Replacement.Text = "<ahead></ahead>"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.HomeKey Unit:=wdLine
Selection.TypeText Text:="<ahead>"
Selection.EndKey Unit:=wdLine
Selection.TypeText Text:="</ahead>"
Loop Until (Selection.End = ActiveDocument.Content.End)
End Sub
I'm sure there is a better way to add xml code to styled text in a
Word doc, but I'm not quite sure where to start. I thought using
macros might be the best solution for now. I work in academic
publishing and our manuscripts need to be marked up with xml for our
typesetters.
Thanks in advance for any help!
Bendte