Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-08-2013, 09:45 AM
d4okeefe d4okeefe is offline Identifying Irregular Characters Windows Vista Identifying Irregular Characters Office 2010 64bit
Advanced Beginner
Identifying Irregular Characters
 
Join Date: Apr 2013
Posts: 77
d4okeefe is on a distinguished road
Default Identifying Irregular Characters

A few years ago I recorded this macro, which is designed to identify irregular characters in a document.



Code:
With Selection.Find
  .ClearFormatting
  .Replacement.ClearFormatting
  .Text = "[!\!-\],_,a-z,§,¶,\, ,^13,^m,^l,^s,^=,^+,^t,^-,“,”,‘,’,^2]"
  .Replacement.Text = ""
  .Forward = True
  .Wrap = wdFindContinue
  .Format = False
  .MatchCase = False
  .MatchWholeWord = False
  .MatchAllWordForms = False
  .MatchSoundsLike = False
  .MatchWildcards = True
  .Execute
End With
As you can see, the macro ignores most characters. But it stops on ligatures like "fi", grave accents (`), and other things unusual.

It works well for our purposes. However, I would like to improve it in two ways.

First, I would like the macro to first look in the main body of the document for irregular characters, then cycle through the footnotes. Right now, it only cycles through the document part where it begins.

Second, I would like macro to also ignore some other characters like m-spaces ChrW(8195) and n-spaces ChrW(8194). It currently stops on those characters as well.

Any ideas? Thank you for your help.

Last edited by macropod; 05-08-2013 at 03:21 PM. Reason: Added code tags & formatting
Reply With Quote
  #2  
Old 05-08-2013, 03:29 PM
macropod's Avatar
macropod macropod is offline Identifying Irregular Characters Windows 7 64bit Identifying Irregular Characters Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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

Try:
Code:
Dim RngStory As Range
For Each RngStory In ActiveDocument.StoryRanges
  With RngStory.Find
    .ClearFormatting
    .Text = "[!\!-\" & ChrW(8195) & ChrW(8194) & "],_,a-z,§,¶,\, ,^13,^m,^l,^s,^=,^+,^t,^-,“,”,‘,’,^2]"
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindContinue
    .Format = False
    .MatchWildcards = True
    .Execute
  End With
Next RngStory
PS: When posting code, please use the code tags. They're on the 'Go Advanced' tab.

Note: If the intention is to have the macro stop at ChrW(8195) & ChrW(8194), change:
.Text = "[!\!-\" & ChrW(8195) & ChrW(8194) & "],_,a-z,§,¶,\, ,^13,^m,^l,^s,^=,^+,^t,^-,“,”,‘,’,^2]"
to:
.Text = "[!\!-\],_,a-z,§,¶,\, ,^13,^m,^l,^s,^=,^+,^t,^-,“,”,‘,’,^2" & ChrW(8195) & ChrW(8194) & "]"
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 05-09-2013, 03:14 PM
d4okeefe d4okeefe is offline Identifying Irregular Characters Windows Vista Identifying Irregular Characters Office 2010 64bit
Advanced Beginner
Identifying Irregular Characters
 
Join Date: Apr 2013
Posts: 77
d4okeefe is on a distinguished road
Default

Thanks for the help.

I realize the .text line was difficult to read. My intention was to build a wildcard that ignores any characters we use in our documents, and highlight ones we don't.

Your fix did the trick. I changed .text line slightly, near the beginning, so that it reads \!-\] and thereby ignores the entire range of characters indicated.

This forum has been a terrific aid.

Daniel
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I turn off newline characters GraeagleBill Word 3 12-18-2012 11:35 PM
Identifying Irregular Characters Identifying and counting words monique Word 1 08-30-2012 05:33 AM
Junk characters (box-like characters) in Word file Sashikala Word 1 04-20-2010 02:03 PM
escape characters LadyReader Word VBA 0 09-06-2006 12:09 PM
Identifying the Dynamic Connector cyberbhai Misc 0 12-14-2005 03:55 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:42 PM.


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