J
JB
Hi Folks,
I'm trying to get a code sample working which finds a particular style (HRef
of which there may be many on the same document) and give the user a choice
of keeping the style of replacing the style with Normal.
Below is what I have so far, problem is I only want it to do this once per
style found and not loop round the document 50 times.
Tips Appreciated
J
Public Sub HRef()
Selection.WholeStory
Selection.MoveLeft wdCharacter, 1
iCount = 0
ActiveDocument.ActiveWindow.View.ShowHiddenText = True
Do Until iCount > 50
If iCount = 0 Then
Selection.HomeKey
End If
Selection.Find.ClearFormatting
Selection.Find.Style = ActiveDocument.Styles("HRef")
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
End With
Selection.Find.Execute
x = Selection.Characters.count
Selection.MoveRight wdCharacter, 1
Selection.MoveRight wdCharacter, 2, wdExtend
If Selection.Style <> "Anchor" Then
Selection.MoveLeft wdCharacter, 1
Selection.MoveLeft wdCharacter, x, wdExtend
Reply = (MsgBox(strMessage, vbYesNo, strTitle))
If Reply = vbYes Then
Selection.Style = "Default Paragraph Font"
End If
Else
bGood = True
End If
iCount = iCount + 1
Loop
End Sub
I'm trying to get a code sample working which finds a particular style (HRef
of which there may be many on the same document) and give the user a choice
of keeping the style of replacing the style with Normal.
Below is what I have so far, problem is I only want it to do this once per
style found and not loop round the document 50 times.
Tips Appreciated
J
Public Sub HRef()
Selection.WholeStory
Selection.MoveLeft wdCharacter, 1
iCount = 0
ActiveDocument.ActiveWindow.View.ShowHiddenText = True
Do Until iCount > 50
If iCount = 0 Then
Selection.HomeKey
End If
Selection.Find.ClearFormatting
Selection.Find.Style = ActiveDocument.Styles("HRef")
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
End With
Selection.Find.Execute
x = Selection.Characters.count
Selection.MoveRight wdCharacter, 1
Selection.MoveRight wdCharacter, 2, wdExtend
If Selection.Style <> "Anchor" Then
Selection.MoveLeft wdCharacter, 1
Selection.MoveLeft wdCharacter, x, wdExtend
Reply = (MsgBox(strMessage, vbYesNo, strTitle))
If Reply = vbYes Then
Selection.Style = "Default Paragraph Font"
End If
Else
bGood = True
End If
iCount = iCount + 1
Loop
End Sub