Detecting hidden text

J

John Doue

I would like to write a macro warning me if when I open or save a
document, this document contains hidden text. How do I detect hidden
text in a macro?

Thanks
 
J

Jay Freedman

John said:
I would like to write a macro warning me if when I open or save a
document, this document contains hidden text. How do I detect hidden
text in a macro?

Thanks

Put this in Normal.dot or another global template (see
http://www.gmayor.com/installing_macro.htm):

Sub AutoOpen()
Dim oRg As Range
Set oRg = ActiveDocument.Range
ActiveWindow.View.ShowHiddenText = True
With oRg.Find
.Format = True
.Forward = True
.Font.Hidden = True
If .Execute Then
oRg.Select
With ActiveWindow.View
.ShowHiddenText = False
.ShowAll = True
End With
MsgBox "Hidden text!"
Else
ActiveWindow.View.ShowHiddenText = False
End If
End With
End Sub
 
J

John Doue

Jay said:
Put this in Normal.dot or another global template (see
http://www.gmayor.com/installing_macro.htm):

Sub AutoOpen()
Dim oRg As Range
Set oRg = ActiveDocument.Range
ActiveWindow.View.ShowHiddenText = True
With oRg.Find
.Format = True
.Forward = True
.Font.Hidden = True
If .Execute Then
oRg.Select
With ActiveWindow.View
.ShowHiddenText = False
.ShowAll = True
End With
MsgBox "Hidden text!"
Else
ActiveWindow.View.ShowHiddenText = False
End If
End With
End Sub
Thanks a lot, I'll try it tomorrow!
 
J

John Doue

Jay said:
Put this in Normal.dot or another global template (see
http://www.gmayor.com/installing_macro.htm):

Sub AutoOpen()
Dim oRg As Range
Set oRg = ActiveDocument.Range
ActiveWindow.View.ShowHiddenText = True
With oRg.Find
.Format = True
.Forward = True
.Font.Hidden = True
If .Execute Then
oRg.Select
With ActiveWindow.View
.ShowHiddenText = False
.ShowAll = True
End With
MsgBox "Hidden text!"
Else
ActiveWindow.View.ShowHiddenText = False
End If
End With
End Sub
Jay,

I just changed ShowhiddentText to True and ShowAll to false, and now, it
works. Thanks again.
 

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