Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-01-2010, 07:53 AM
Takket Takket is offline Help with a macro Windows XP Help with a macro Office 2000
Novice
Help with a macro
 
Join Date: Jan 2010
Posts: 2
Takket is on a distinguished road
Default Help with a macro

I wrote this macro to find all the hidden text in a document, and replace it with nothing (delete it). The problem is, it is doing the EXACT OPPOSITE. It is finding all the NOT hidden text and deleting it. After I run the macro, if I click on "Edit-Replace" it says "Not Hidden" in the find window. It should just say "Hidden." What am I doing wrong?

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
Reply With Quote
  #2  
Old 03-28-2014, 10:34 AM
Larry Sulky Larry Sulky is offline Help with a macro Windows 7 64bit Help with a macro Office 2010 64bit
Novice
 
Join Date: Mar 2014
Posts: 14
Larry Sulky is on a distinguished road
Default

Try this before you run the Selection.Find:

ActiveWindow.View.ShowHiddenText = True

BTW, I tried your code as-is and it merely failed; it didn't remove un-hidden text.
Reply With Quote
  #3  
Old 03-28-2014, 04:58 PM
macropod's Avatar
macropod macropod is online now Help with a macro Windows 7 32bit Help with a macro Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 19,792
macropod has much to be proud ofmacropod has much to be proud ofmacropod has much to be proud ofmacropod has much to be proud ofmacropod has much to be proud ofmacropod has much to be proud ofmacropod has much to be proud ofmacropod has much to be proud of
Default

This works for me:
Code:
Sub Demo()
With ActiveDocument.Content.Find
  .ClearFormatting
  .Replacement.ClearFormatting
  .Text = ""
  .Replacement.Text = ""
  .Format = True
  .Font.Hidden = True
  .Forward = True
  .Wrap = wdFindContinue
  .Execute Replace:=wdReplaceAll
End With
End Sub
PS: When posting code, please use the code tags. They're on the 'Go Advanced' tab.
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with a macro Macro Tutorials TAFE Word 4 11-04-2009 02:50 AM
Macro library pankajkankaria Excel 1 04-12-2009 09:06 AM
macro on checkbox macrohelp Word VBA 0 03-06-2009 03:33 PM
Unable to run the specified macro jtrirogoff Word 0 02-05-2009 04:38 PM
Macro Issue Basanth Excel 1 12-05-2008 08:07 PM


All times are GMT -7. The time now is 04:30 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2020 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft