Hello,
How might I run a search ad replace (in macro form) where the style changes is applied only to a portion of a hyperlinked string. I always lose the hyperlink in the replaced portion
Example
Say I have the following string:
Section X of the Interpretation Act
The entire string is hyperlinked with the following link (kept brief for the question):
http://www.e-laws.gov.on.ca/sectionX
The "Interpretation Act" section must be styled with Emphasis.
When I run the following macro, the hyperlink is stripped from the newly stylized segment leaving only "Section X" hyperlinked.
So this:
Section X of the Interpretation Act
becomes this:
Section X of the Interpretation Act
Code:
Sub StyleChange()
'
' StyleChange Macro
'
'
Selection.ParagraphFormat.Alignment = wdAlignParagraphJustify
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Style = ActiveDocument.Styles("Emphasis")
With Selection.Find
.Text = "Interpretation Act"
.Replacement.Text = "Interpretation Act"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub