VBA to test for hidden text

F

Fxrobots

Hi Guys

Is there a way of testing for hidden text in a document when the user
opens the document?

Thanks
 
G

Graham Mayor

The following macro may help, though it will not see all story ranges in
this form.

Dim bHidden As Boolean
Dim oRng As Range
bHidden = ActiveWindow.View.ShowHiddenText
ActiveWindow.View.ShowHiddenText = True
With Selection
.HomeKey wdStory
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = ""
.Replacement.Text = ""
.Font.Hidden = True
.Forward = True
.Wrap = wdFindStop
.format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
If .Execute = True Then
MsgBox "The document contains hidden text"
Else
MsgBox "No hidden text found"
End If
End With
End With
ActiveWindow.View.ShowHiddenText = bHidden

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
G

Graham Mayor

You are welcome :)

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top