Office 2010/Word macros

Advertisement


Question
Hi Steven,

I have a word project I need to get started and it involves macros searching a doc and if it meets a criteria, change it to X. For example, we use templates that have hidden text used as instructions and I want a macro to search the doc and remove it. I have a lot of different examples of this - changing blue boiler plate text to black, adding header/footer info or removing header/footer info. So, to get started, can you help me with a macro that searches a doc for hidden text and removes it. Also, any other books or websites that you think would be helpful to me.

Regards,

Chris

Answer
Hi Chris,

The macro I have included below should do the trick for you:

Sub RemoveHiddenText()
Dim sView As Boolean
sView = ActiveWindow.View.ShowHiddenText
ActiveWindow.View.ShowHiddenText = True
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ""
'********************
.Font.Hidden = True
'********************
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
ActiveWindow.View.ShowHiddenText = sView
End Sub

----

As for reference materials, I would suggest visiting some forums such as ExcelForums (they are not striclty for Excel and have Word threads as well) and even sticking with the Microsoft Support / Community sites.

If you need any help, please let me know!

Kind Regards,
Steve

Office 2010

All Answers


Answers by Expert:


Ask Experts

Volunteer


Steven Harris

Expertise

I am proficient in all MS Office features, including but not limited to Visual Basic (Macros), Document Protection, Active-X Controls and Developer Features.

Experience

I have an extensive educational, vocational and business background extending over 12 years in information technology.

Organizations
Association of Information Technology Professionals IEEE Computer Society Texas Professionals Texas Young Professionals Excel Developers Excel Blackbelts

Education/Credentials
Microsoft Certified Technology Specialist (MCTS) Program Microsoft Office Expert Program

©2016 About.com. All rights reserved.