Hello,
I'm using the word VBA macro to show the number of hidden text in the word document, the below code works perfect fine, however if the last hidden text found in the document meets this criteria (entire paragraph in a table cell was hidden) then it loops again and again, not coming out of the loop.
Please help me.
Code:
Sub Test1()
Dim oRg As Range
Set oRg = ActiveDocument.Range
ActiveWindow.View.ShowHiddenText = True
With oRg.Find
.Format = True
.Forward = True
.Font.Hidden = True
a:
If .Execute Then
oRg.Select
With ActiveWindow.View
.ShowHiddenText = False
.ShowAll = True
End With
MsgBox oRg.Text
GoTo a:
Else
ActiveWindow.View.ShowHiddenText = False
End If
End With
End Sub
I'm using the word VBA macro to show the number of hidden text in the word document, the below code works perfect fine, however if the last hidden text found in the document meets this criteria (entire paragraph in a table cell was hidden) then it loops again and again, not coming out of the loop.
Please help me.
Code:
Sub Test1()
Dim oRg As Range
Set oRg = ActiveDocument.Range
ActiveWindow.View.ShowHiddenText = True
With oRg.Find
.Format = True
.Forward = True
.Font.Hidden = True
a:
If .Execute Then
oRg.Select
With ActiveWindow.View
.ShowHiddenText = False
.ShowAll = True
End With
MsgBox oRg.Text
GoTo a:
Else
ActiveWindow.View.ShowHiddenText = False
End If
End With
End Sub