Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

replace ALL symbols in Word.

499 views
Skip to first unread message

jason

unread,
Mar 20, 2002, 8:09:31 PM3/20/02
to
I have done quite a bit of research on replacing word
symbols with plain text. I want to find andd replace any
symbol with the text "unknown chararcter", but I dont want
the performance hit of going through each character in the
entire document.

In psudo-code, I want this:

With Selection.find

.Wrap = wdFindContinue
.Text = chrw(>255) and chrw(<0)
.Replacement.Text = "unknown character"
.Execute Replace:=wdReplaceAll

End With

ALSO: Another problem (MS is aware of) is that Symbols of
font Symbol have a chrw value of 40. The left
paranthesis. This is totally screwy, and the only way to
get the 'real' value is by selecting the symbol manually,
and running this:

Dim dlg As Dialog
Set dlg = Dialogs(wdDialogInsertSymbol)

Dim UniCodeNum As String
UniCodeNum = dlg.charnum

MsgBox UniCodeNum

where, UniCodeNum will give the numeric representation
that Chrw will not.

I CANT go though a 200 page document, select the first
character, determine if its a Unicode, process it, then go
on.

Any help would be GREATLY appreciated!

Thanks, Jason

Klaus Linke

unread,
Mar 20, 2002, 10:26:03 PM3/20/02
to
Hi Jason,

Those symbols are a terrible nuisance. Symbols from "decorative" fonts
(that is old, non-Unicode fonts) have a ChrW-value of 40 if they are
inserted with "Insert > Symbol". I call them "protected", because they
won't change if you select them and try to assign another font.
But if you just type them in, they have ChrW-values between 61472 and
61695 (and are "unprotected": you can change the font). All these old
fonts use the same code page (starting at hexadecimal &HF000 = 61440)
in Word.

Your pseudo-code


.Text = chrw(>255) and chrw(<0)

would be
.Text = chrw(>=61472) and chrw(<=61695)
for symbols from decorative fonts (Symbol, Wingdings, Dingbats ...).

or
.Text = ChrW(>=256) and ChrW(<=65535)
if you want to find all "upper Unicode" characters and symbols
(including smart quotes, En-dashes ...).


The search for symbols from decorative fonts can be translated to a
wildcard search like this:
.Text = "[" & ChrW(61472) & "-" & ChrW(61695) & "]"
.MatchWildcards = True

This will even find "protected" symbols; so if you just want to
replace all symbols from decorative fonts with the same marker, this
would already do the job.

But you will usually put in different markers for different symbols.
As an additional complication, you won't find protected symbols if you
search for the symbol font, so if your document contains protected
symbols from different fonts, you cannot tell them apart.

To make life easier, I have written a macro to convert the "protected"
ChrW(40) symbols to regular "unprotected" symbols that you can easily
find and replace (see below).

The macro works just like yours, it just deletes the protected symbol
and re-inserts it unprotected, instead of displaying the code. It will
take a while to run on a 200-page-document (but beats looking the
symbols up manually).

If you are interested in "real" Unicode characters (bullets or
greek/cyrillic letters from Arial or Times New Roman, and all the rest
..., you can find them like any other ordinary letter, for example you
can copy them from the text to the clipboard (Ctrl+C), and insert them
in "Find what" (Ctrl+V).
Or you can use the code. The "Insert > Symbol" dialog shows the
hexadecimal code only (in Word2000), while you usually want the
decimal code to search for them:
^u8364 will find the "Euro" symbol (decimal code 8364, Hecadecimal
code 20AC; the latter is displayed in the status bar of the document
if you select the symbol in the dialog).

You can convert the numbers using the windows calculator (with
scientific display), if you use the "hex" and "dec" buttons.

Hope this will help to speed up your task
Greetings, Klaus


Sub SymbolsUnprotect()
'
Dim SelFont, SelCharNum

Selection.Collapse (wdCollapseStart)
Selection.Find.ClearFormatting
With Selection.Find
.text = "[" & ChrW(61472) & "-" & ChrW(61695) & "]"
.Replacement.text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
While Selection.Find.Execute
With Dialogs(wdDialogInsertSymbol)
SelFont = .Font
SelCharNum = .charnum
End With

Selection.Font.Name = SelFont
Selection.TypeText text:=ChrW(SelCharNum)

' replace the last 2 lines with the following to
' ptotect symbols from decorative fonts:
' Selection.InsertSymbol _
' Font:=SelFont, _
' CharacterNumber:=SelCharNum, _
' Unicode:=True

Wend
End Sub

Alix Hartman

unread,
Mar 21, 2002, 12:55:48 AM3/21/02
to
I've done something similar. I had hundreds of pages that used a
combination of English alphabet and some special symbols for Native American
languages. I made a macro to find and replace all the symbols with a plain
text character. Then as I opened each document, I just ran the macro, and
saved it as a new document.

Can you try making a macro?

--

Alix
al...@BINKY.pacifier.com
[To respond, first take out the binky]

"Klaus Linke" <fotosatz...@t-online.de> wrote in message
news:a7bjt9$jhc$05$1...@news.t-online.com...

Klaus Linke

unread,
Mar 21, 2002, 1:41:55 AM3/21/02
to
"Alix Hartman" <al...@BINKY.pacifier.com> wrote:
> I've done something similar. I had hundreds of pages that used a
> combination of English alphabet and some special symbols for
> Native American languages. I made a macro to find and replace all
> the symbols with a plain text character. Then as I opened each
> document, I just ran the macro, and saved it as a new document.
>
> Can you try making a macro?


Hi Jason, hi Alix,

I wrote the macro below a while ago, but hardly used it myself.

It converts symbols from the "Symbol" font to regular Unicode
characters (in font Arial, Times New Roman, or whatever is used in
the applied style).
The improvised "progress bar" doesn't work properly, and there may be
other bugs.

You should run "SymbolsUnprotect" from my last post first. If you run
into problems, I'd appreciate any feedback, so that I can improve on
it.

The macro is pretty slow, because it was written to work with
formatted documents, and should keep the formatting.

Alix: I think you were suggesting a macro to Jason ... or were you
asking for help with your macro?
If your files are plain, unformatted text files, it would be possible
to write much quicker macros than the one below that use the VBA
string functions.

Greetings, Klaus


Sub SymbolToUnicode()
' Select document or range before running the macro
Dim myFont As String
Dim myCharNum As Long
Dim myRange As Range
Dim myChar As Range
Dim i As Long, CharCount As Long
Set myRange = Selection.Range.Duplicate
CharCount = myRange.ComputeStatistics(wdStatisticCharacters)
For Each myChar In myRange.Characters
i = i + 1
StatusBar = Format(100 * i / CharCount, "###") & "%"
If myChar.Font.Name = "Symbol" Then
myCharNum = AscW(myChar.text) And &HFFFF&
' Decorative Fonts are mapped to a
' "private use" code page starting at &HF000
myCharNum = myCharNum - &HF000&
myChar.Font.Name = myChar.Style.Font.Name
Select Case myCharNum
Case &H22 ' # FOR ALL
myChar.text = ChrW(&H2200)
Case &H24 ' # THERE EXISTS
myChar.text = ChrW(&H2203)
Case &H27 ' # CONTAINS AS MEMBER
myChar.text = ChrW(&H220B)
Case &H2A ' # ASTERISK OPERATOR
myChar.text = ChrW(&H2217)
Case &H2D ' # MINUS SIGN
myChar.text = ChrW(&H2212)
Case &H40 ' # APPROXIMATELY EQUAL TO
myChar.text = ChrW(&H2245)
Case &H41 ' # GREEK CAPITAL LETTER ALPHA
myChar.text = ChrW(&H391)
Case &H42 ' # GREEK CAPITAL LETTER BETA
myChar.text = ChrW(&H392)
Case &H43 ' # GREEK CAPITAL LETTER CHI
myChar.text = ChrW(&H3A7)
Case &H44 ' # GREEK CAPITAL LETTER DELTA
myChar.text = ChrW(&H394)
Case &H44 ' # INCREMENT
myChar.text = ChrW(&H2206)
Case &H45 ' # GREEK CAPITAL LETTER EPSILON
myChar.text = ChrW(&H395)
Case &H46 ' # GREEK CAPITAL LETTER PHI
myChar.text = ChrW(&H3A6)
Case &H47 ' # GREEK CAPITAL LETTER GAMMA
myChar.text = ChrW(&H393)
Case &H48 ' # GREEK CAPITAL LETTER ETA
myChar.text = ChrW(&H397)
Case &H49 ' # GREEK CAPITAL LETTER IOTA
myChar.text = ChrW(&H399)
Case &H4A ' # GREEK THETA SYMBOL
myChar.text = ChrW(&H3D1)
Case &H4B ' # GREEK CAPITAL LETTER KAPPA
myChar.text = ChrW(&H39A)
Case &H4C ' # GREEK CAPITAL LETTER LAMDA
myChar.text = ChrW(&H39B)
Case &H4D ' # GREEK CAPITAL LETTER MU
myChar.text = ChrW(&H39C)
Case &H4E ' # GREEK CAPITAL LETTER NU
myChar.text = ChrW(&H39D)
Case &H4F ' # GREEK CAPITAL LETTER OMICRON
myChar.text = ChrW(&H39F)
Case &H50 ' # GREEK CAPITAL LETTER PI
myChar.text = ChrW(&H3A0)
Case &H51 ' # GREEK CAPITAL LETTER THETA
myChar.text = ChrW(&H398)
Case &H52 ' # GREEK CAPITAL LETTER RHO
myChar.text = ChrW(&H3A1)
Case &H53 ' # GREEK CAPITAL LETTER SIGMA
myChar.text = ChrW(&H3A3)
Case &H54 ' # GREEK CAPITAL LETTER TAU
myChar.text = ChrW(&H3A4)
Case &H55 ' # GREEK CAPITAL LETTER UPSILON
myChar.text = ChrW(&H3A5)
Case &H56 ' # GREEK SMALL LETTER FINAL SIGMA
myChar.text = ChrW(&H3C2)
Case &H57 ' # GREEK CAPITAL LETTER OMEGA
myChar.text = ChrW(&H3A9)
Case &H57 ' # OHM SIGN
myChar.text = ChrW(&H2126)
Case &H58 ' # GREEK CAPITAL LETTER XI
myChar.text = ChrW(&H39E)
Case &H59 ' # GREEK CAPITAL LETTER PSI
myChar.text = ChrW(&H3A8)
Case &H5A ' # GREEK CAPITAL LETTER ZETA
myChar.text = ChrW(&H396)
Case &H5C ' # THEREFORE
myChar.text = ChrW(&H2234)
Case &H5E ' # UP TACK
myChar.text = ChrW(&H22A5)
Case &H60 ' # RADICAL EXTENDER
myChar.text = ChrW(&HF8E5)
Case &H61 ' # GREEK SMALL LETTER ALPHA
myChar.text = ChrW(&H3B1)
Case &H62 ' # GREEK SMALL LETTER BETA
myChar.text = ChrW(&H3B2)
Case &H63 ' # GREEK SMALL LETTER CHI
myChar.text = ChrW(&H3C7)
Case &H64 ' # GREEK SMALL LETTER DELTA
myChar.text = ChrW(&H3B4)
Case &H65 ' # GREEK SMALL LETTER EPSILON
myChar.text = ChrW(&H3B5)
Case &H66 ' # GREEK SMALL LETTER PHI
myChar.text = ChrW(&H3C6)
Case &H67 ' # GREEK SMALL LETTER GAMMA
myChar.text = ChrW(&H3B3)
Case &H68 ' # GREEK SMALL LETTER ETA
myChar.text = ChrW(&H3B7)
Case &H69 ' # GREEK SMALL LETTER IOTA
myChar.text = ChrW(&H3B9)
Case &H6A ' # GREEK PHI SYMBOL
myChar.text = ChrW(&H3D5)
Case &H6B ' # GREEK SMALL LETTER KAPPA
myChar.text = ChrW(&H3BA)
Case &H6C ' # GREEK SMALL LETTER LAMDA
myChar.text = ChrW(&H3BB)
Case &H6D ' # MICRO SIGN
myChar.text = ChrW(&HB5)
Case &H6D ' # GREEK SMALL LETTER MU
myChar.text = ChrW(&H3BC)
Case &H6E ' # GREEK SMALL LETTER NU
myChar.text = ChrW(&H3BD)
Case &H6F ' # GREEK SMALL LETTER OMICRON
myChar.text = ChrW(&H3BF)
Case &H70 ' # GREEK SMALL LETTER PI
myChar.text = ChrW(&H3C0)
Case &H71 ' # GREEK SMALL LETTER THETA
myChar.text = ChrW(&H3B8)
Case &H72 ' # GREEK SMALL LETTER RHO
myChar.text = ChrW(&H3C1)
Case &H73 ' # GREEK SMALL LETTER SIGMA
myChar.text = ChrW(&H3C3)
Case &H74 ' # GREEK SMALL LETTER TAU
myChar.text = ChrW(&H3C4)
Case &H75 ' # GREEK SMALL LETTER UPSILON
myChar.text = ChrW(&H3C5)
Case &H76 ' # GREEK PI SYMBOL
myChar.text = ChrW(&H3D6)
Case &H77 ' # GREEK SMALL LETTER OMEGA
myChar.text = ChrW(&H3C9)
Case &H78 ' # GREEK SMALL LETTER XI
myChar.text = ChrW(&H3BE)
Case &H79 ' # GREEK SMALL LETTER PSI
myChar.text = ChrW(&H3C8)
Case &H7A ' # GREEK SMALL LETTER ZETA
myChar.text = ChrW(&H3B6)
Case &H7E ' # TILDE OPERATOR
myChar.text = ChrW(&H223C)
Case &HA0 ' # EURO SIGN
myChar.text = ChrW(&H20AC)
Case &HA1 ' # GREEK UPSILON WITH HOOK SYMBOL
myChar.text = ChrW(&H3D2)
Case &HA2 ' # PRIME
myChar.text = ChrW(&H2032)
Case &HA3 ' # LESS-THAN OR EQUAL TO
myChar.text = ChrW(&H2264)
Case &HA4 ' # FRACTION SLASH
myChar.text = ChrW(&H2044)
Case &HA4 ' # DIVISION SLASH
myChar.text = ChrW(&H2215)
Case &HA5 ' # INFINITY
myChar.text = ChrW(&H221E)
Case &HA6 ' # LATIN SMALL LETTER F WITH HOOK
myChar.text = ChrW(&H192)
Case &HA7 ' # BLACK CLUB SUIT
myChar.text = ChrW(&H2663)
Case &HA8 ' # BLACK DIAMOND SUIT
myChar.text = ChrW(&H2666)
Case &HA9 ' # BLACK HEART SUIT
myChar.text = ChrW(&H2665)
Case &HAA ' # BLACK SPADE SUIT
myChar.text = ChrW(&H2660)
Case &HAB ' # LEFT RIGHT ARROW
myChar.text = ChrW(&H2194)
Case &HAC ' # LEFTWARDS ARROW
myChar.text = ChrW(&H2190)
Case &HAD ' # UPWARDS ARROW
myChar.text = ChrW(&H2191)
Case &HAE ' # RIGHTWARDS ARROW
myChar.text = ChrW(&H2192)
Case &HAF ' # DOWNWARDS ARROW
myChar.text = ChrW(&H2193)
Case &HB2 ' # DOUBLE PRIME
myChar.text = ChrW(&H2033)
Case &HB3 ' # GREATER-THAN OR EQUAL TO
myChar.text = ChrW(&H2265)
Case &HB4 ' # MULTIPLICATION SIGN
myChar.text = ChrW(&HD7)
Case &HB5 ' # PROPORTIONAL TO
myChar.text = ChrW(&H221D)
Case &HB6 ' # PARTIAL DIFFERENTIAL
myChar.text = ChrW(&H2202)
Case &HB7 ' # BULLET
myChar.text = ChrW(&H2022)
Case &HB8 ' # DIVISION SIGN
myChar.text = ChrW(&HF7)
Case &HB9 ' # NOT EQUAL TO
myChar.text = ChrW(&H2260)
Case &HBA ' # IDENTICAL TO
myChar.text = ChrW(&H2261)
Case &HBB ' # ALMOST EQUAL TO
myChar.text = ChrW(&H2248)
Case &HBC ' # HORIZONTAL ELLIPSIS
myChar.text = ChrW(&H2026)
Case &HBD ' # VERTICAL ARROW EXTENDER
myChar.text = ChrW(&HF8E6)
Case &HBE ' # HORIZONTAL ARROW EXTENDER
myChar.text = ChrW(&HF8E7)
Case &HBF ' # DOWNWARDS ARROW WITH CORNER LEFTWARDS
myChar.text = ChrW(&H21B5)
Case &HC0 ' # ALEF SYMBOL
myChar.text = ChrW(&H2135)
Case &HC1 ' # BLACK-LETTER CAPITAL I
myChar.text = ChrW(&H2111)
Case &HC2 ' # BLACK-LETTER CAPITAL R
myChar.text = ChrW(&H211C)
Case &HC3 ' # SCRIPT CAPITAL P
myChar.text = ChrW(&H2118)
Case &HC4 ' # CIRCLED TIMES
myChar.text = ChrW(&H2297)
Case &HC5 ' # CIRCLED PLUS
myChar.text = ChrW(&H2295)
Case &HC6 ' # EMPTY SET
myChar.text = ChrW(&H2205)
Case &HC7 ' # INTERSECTION
myChar.text = ChrW(&H2229)
Case &HC8 ' # UNION
myChar.text = ChrW(&H222A)
Case &HC9 ' # SUPERSET OF
myChar.text = ChrW(&H2283)
Case &HCA ' # SUPERSET OF OR EQUAL TO
myChar.text = ChrW(&H2287)
Case &HCB ' # NOT A SUBSET OF
myChar.text = ChrW(&H2284)
Case &HCC ' # SUBSET OF
myChar.text = ChrW(&H2282)
Case &HCD ' # SUBSET OF OR EQUAL TO
myChar.text = ChrW(&H2286)
Case &HCE ' # ELEMENT OF
myChar.text = ChrW(&H2208)
Case &HCF ' # NOT AN ELEMENT OF
myChar.text = ChrW(&H2209)
Case &HD0 ' # ANGLE
myChar.text = ChrW(&H2220)
Case &HD1 ' # NABLA
myChar.text = ChrW(&H2207)
Case &HD2 ' # REGISTERED SIGN SERIF
myChar.text = ChrW(&HF6DA)
Case &HD3 ' # COPYRIGHT SIGN SERIF
myChar.text = ChrW(&HF6D9)
Case &HD4 ' # TRADE MARK SIGN SERIF
myChar.text = ChrW(&HF6DB)
Case &HD5 ' # N-ARY PRODUCT
myChar.text = ChrW(&H220F)
Case &HD6 ' # SQUARE ROOT
myChar.text = ChrW(&H221A)
Case &HD7 ' # DOT OPERATOR
myChar.text = ChrW(&H22C5)
Case &HD8 ' # NOT SIGN
myChar.text = ChrW(&HAC)
Case &HD9 ' # LOGICAL AND
myChar.text = ChrW(&H2227)
Case &HDA ' # LOGICAL OR
myChar.text = ChrW(&H2228)
Case &HDB ' # LEFT RIGHT DOUBLE ARROW
myChar.text = ChrW(&H21D4)
Case &HDC ' # LEFTWARDS DOUBLE ARROW
myChar.text = ChrW(&H21D0)
Case &HDD ' # UPWARDS DOUBLE ARROW
myChar.text = ChrW(&H21D1)
Case &HDE ' # RIGHTWARDS DOUBLE ARROW
myChar.text = ChrW(&H21D2)
Case &HDF ' # DOWNWARDS DOUBLE ARROW
myChar.text = ChrW(&H21D3)
Case &HE0 ' # LOZENGE
myChar.text = ChrW(&H25CA)
Case &HE1 ' # LEFT-POINTING ANGLE BRACKET
myChar.text = ChrW(&H2329)
Case &HE2 ' # REGISTERED SIGN SANS SERIF
myChar.text = ChrW(&HF8E8)
Case &HE3 ' # COPYRIGHT SIGN SANS SERIF
myChar.text = ChrW(&HF8E9)
Case &HE4 ' # TRADE MARK SIGN SANS SERIF
myChar.text = ChrW(&HF8EA)
Case &HE5 ' # N-ARY SUMMATION
myChar.text = ChrW(&H2211)
Case &HE6 ' # LEFT PAREN TOP
myChar.text = ChrW(&HF8EB)
Case &HE7 ' # LEFT PAREN EXTENDER
myChar.text = ChrW(&HF8EC)
Case &HE8 ' # LEFT PAREN BOTTOM
myChar.text = ChrW(&HF8ED)
Case &HE9 ' # LEFT SQUARE BRACKET TOP
myChar.text = ChrW(&HF8EE)
Case &HEA ' # LEFT SQUARE BRACKET EXTENDER
myChar.text = ChrW(&HF8EF)
Case &HEB ' # LEFT SQUARE BRACKET BOTTOM
myChar.text = ChrW(&HF8F0)
Case &HEC ' # LEFT CURLY BRACKET TOP
myChar.text = ChrW(&HF8F1)
Case &HED ' # LEFT CURLY BRACKET MID
myChar.text = ChrW(&HF8F2)
Case &HEE ' # LEFT CURLY BRACKET BOTTOM
myChar.text = ChrW(&HF8F3)
Case &HEF ' # CURLY BRACKET EXTENDER
myChar.text = ChrW(&HF8F4)
Case &HF1 ' # RIGHT-POINTING ANGLE BRACKET
myChar.text = ChrW(&H232A)
Case &HF2 ' # INTEGRAL
myChar.text = ChrW(&H222B)
Case &HF3 ' # TOP HALF INTEGRAL
myChar.text = ChrW(&H2320)
Case &HF4 ' # INTEGRAL EXTENDER
myChar.text = ChrW(&HF8F5)
Case &HF5 ' # BOTTOM HALF INTEGRAL
myChar.text = ChrW(&H2321)
Case &HF6 ' # RIGHT PAREN TOP
myChar.text = ChrW(&HF8F6)
Case &HF7 ' # RIGHT PAREN EXTENDER
myChar.text = ChrW(&HF8F7)
Case &HF8 ' # RIGHT PAREN BOTTOM
myChar.text = ChrW(&HF8F8)
Case &HF9 ' # RIGHT SQUARE BRACKET TOP
myChar.text = ChrW(&HF8F9)
Case &HFA ' # RIGHT SQUARE BRACKET EXTENDER
myChar.text = ChrW(&HF8FA)
Case &HFB ' # RIGHT SQUARE BRACKET BOTTOM
myChar.text = ChrW(&HF8FB)
Case &HFC ' # RIGHT CURLY BRACKET TOP
myChar.text = ChrW(&HF8FC)
Case &HFD ' # RIGHT CURLY BRACKET MID
myChar.text = ChrW(&HF8FD)
Case &HFE ' # RIGHT CURLY BRACKET BOTTOM
myChar.text = ChrW(&HF8FE)
End Select
i = i - 1
End If
Next myChar
myRange.Select
StatusBar = "Finished changing ""Symbol"" font to Unicode"
End Sub


jason

unread,
Mar 21, 2002, 10:22:15 AM3/21/02
to
Amazing. Absolutely perfect answer, that first macro is
exactly what I needed. Thanks a million.

Jason

> Í{ wÀ ¨ dq; Ì P
>To° °ìF Case &H46 ' # GREEK CAPITAL LETTER PHI

Alix Hartman

unread,
Mar 21, 2002, 11:51:49 PM3/21/02
to
Hi Jason -- You made my day! I helped somebody and it worked and I got thanked. Alix al...@BINKY.pacifier.com [To respond, first take out the binky] "jason" <jfar...@bond.com> wrote in message news:043201c1d0ec$2e4c0dc0$b1e62ecf@tkmsftngxa04... Amazing. Absolutely perfect answer, that first macro is exactly what I needed. Thanks a million. Jason >-----Original Message----- >"Alix Hartman" <al...@BINKY.pacifier.com> wrote: >> I've done something similar. I had hundreds of pages that used a >> combination of English alphabet and some special symbols for >> Native American languages. I made a macro to find and replace all >> the symbols with a plain text character. Then as I opened each >> document, I just ran the macro, and saved it as a new document. >> Can you try making a macro? >Hi Jason, hi Alix, >I wrote the macro below a while ago, but hardly used it myself. >It converts symbols from the "Symbol" font to regular Unicode >characters (in font Arial, Times New Roman, or whatever is used in >the applied style). >The improvised "progress bar" doesn't work properly, and there may be >other bugs. >You should run "SymbolsUnprotect" from my last post first. If you run >into problems, I'd appreciate any feedback, so that I can improve on >it. >The macro is pretty slow, because it was written to work with >formatted documents, and should keep the formatting. >Alix: I think you were suggesting a macro to Jason ... or were you >asking for help with your macro? >If your files are plain, unformatted text files, it would be possible >to write much quicker macros than the one below that use the VBA >string functions. >Greetings, Klaus >Sub SymbolToUnicode() > ' Select document or range before running the macro > Dim myFont As String > Dim myCharNum As Long > Dim myRange As Range > Dim myChar As Range > Dim i As Long, CharCount As Long > Set myRange = Selection.Range.Duplicate > CharCount = myRange.ComputeStatistics (wdStatisticCharacters) > For Each myChar In myRange.Characters > i = i + 1 > StatusBar = Format(100 * i / CharCount, "###") & "%" > If myChar.Font.Name = "Symbol" Then > myCharNum = AscW(myChar.text) And &HFFFF& > ' Decorative Fonts are mapped to a > ' "private use" code page starting at &HF000 > myCharNum = myCharNum - &HF000& > myChar.Font.Name = myChar.Style.Font.Name > Select Case myCharNum > Case &H22 ' # FOR ALL > myChar.text = ChrW(&H2200) > Case &H24 ' # THERE EXISTS > myChar.text = ChrW(&H2203) > Case &H27 ' # CONTAINS AS MEMBER > myChar.text = ChrW(&H220B) > Case &H2A ' # ASTERISK OPERATOR > myChar.text = ChrW(&H2217) > Case &H2D ' # MINUS SIGN > myChar.text = ChrW(&H2212) > Case &H40 ' # APPROXIMATELY EQUAL TO > myChar.text = ChrW(&H2245) > Case &H41 ' # GREEK CAPITAL LETTER ALPHA > myChar.text = ChrW(&H391) > Case &H42 ' # GREEK CAPITAL LETTER BETA > myChar.text = ChrW(&H392) > Case &H43 ' # GREEK CAPITAL LETTER CHI > myChar.text = ChrW(&H3A7) > Case &H44 ' # GREEK CAPITAL LETTER DELTA > myChar.text = ChrW(&H394) > Case &H44 ' # INCREMENT > myChar.text = ChrW(&H2206) > Case &H45 ' # GREEK CAPITAL LETTER EPSILON > myChar.text = ChrW(&H395) > Case &H46 ' # GREEK CAPITAL LETTER PHI > myChar.text = ChrW(&H3A6) > Case &H47 ' # GREEK CAPITAL LETTER GAMMA > myChar.text = ChrW(&H393) > Case &H48 ' # GREEK CAPITAL LETTER ETA > myChar.text = ChrW(&H397) > Case &H49 ' #

Klaus Linke

unread,
Mar 22, 2002, 12:32:09 AM3/22/02
to
"Alix Hartman" <al...@BINKY.pacifier.com> wrote:
> Hi Jason --
> You made my day! I helped somebody and it worked and I got
thanked.
> :-)


Mine, too :-)

Klaus


0 new messages