Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-06-2012, 02:24 AM
tinfanide tinfanide is offline Find & Replace: substitute red-coloured words with underscores Windows 7 64bit Find & Replace: substitute red-coloured words with underscores Office 2010 32bit
Expert
Find & Replace: substitute red-coloured words with underscores
 
Join Date: Aug 2011
Posts: 312
tinfanide is on a distinguished road
Default Find & Replace: substitute red-coloured words with underscores


Find & Replace.doc

Please see the attachment. Many thanks.
Reply With Quote
  #2  
Old 10-06-2012, 09:20 PM
macropod's Avatar
macropod macropod is offline Find & Replace: substitute red-coloured words with underscores Windows 7 64bit Find & Replace: substitute red-coloured words with underscores Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,931
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi Tinfanide,

Replacing character-for-character with underscores is easy enough unsing Find/Replace, but:
• underscores are typically not the same width as the other characters you'll be replacing (see https://www.msofficeforums.com/word/...html#post38158 for comparative widths in 12pt TNR). That means one would have to calculate the string width, then substitute however many underscores will give an approximation of that width; and
• things can get very messy where line breaks are involved. In effect, each line has to be processed independently.
Ultimately, a fairly complex macro would be required. If this is for redaction purposes, see: http://redaction.codeplex.com/
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 10-06-2012, 11:04 PM
tinfanide tinfanide is offline Find & Replace: substitute red-coloured words with underscores Windows 7 64bit Find & Replace: substitute red-coloured words with underscores Office 2010 32bit
Expert
Find & Replace: substitute red-coloured words with underscores
 
Join Date: Aug 2011
Posts: 312
tinfanide is on a distinguished road
Default

Yes, ya're right, macropod.

Before I asked, I'd forgotten one thing. I just used the Format option in the Find And Replace box without specifying the use of wildcards (?) and ended up with

a block of words (with the formatting) turning out to be just a single underscore and

that's why I came here and asked. Now just put ? in the Find What area and Replace all and it does what I have wanted.

And even before I used such a simple Find/Replace function, I'd written a macro:

Code:
Sub test()

With ActiveDocument.Range.Find
    .ClearFormatting
    .ClearHitHighlight
    .MatchWildcards = True
    .Forward = True
    .Wrap = wdFindContinue
    .Font.ColorIndex = wdRed
    .Execute FindText:="?", Format:=True, ReplaceWith:="_", Replace:=wdReplaceAll
End With

End Sub
But of course, it does not accurately deal with the length of different characters as you said.

Thank you for the references given.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find & Replace: substitute red-coloured words with underscores Macro to replace few words in the document ubns Word VBA 7 08-16-2012 10:33 PM
Find & Replace: substitute red-coloured words with underscores Bad view when using Find and Find & Replace - Word places found string on top line paulkaye Word 4 12-06-2011 11:05 PM
Find & Replace: substitute red-coloured words with underscores Is there a way to use "find/replace" to find italics words? slayda Word 3 09-14-2011 02:16 PM
Find & Replace: substitute red-coloured words with underscores Help with find and replace or query and replace shabbaranks Excel 4 03-19-2011 08:38 AM
Find & Replace: substitute red-coloured words with underscores Find & Replace words with "/" prefix & suffix tollanarama Word 4 01-25-2011 02:19 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:25 PM.


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