Find A and @ replace with "quotes"

56 views
Skip to first unread message

kerri

unread,
May 5, 2003, 5:04:04 PM5/5/03
to
Hi,

When converting a WP document over to Word the best
solution has been to paste unformatted text. This works
great unless the WP document contains WP Typographical
symbols for the quotes. When it is pasted unformatted the
beginning quote become an A and the ending quote becomes
an @. All apostrophes become = and more.

I need to do a find and replace for ASingle Person@ and
the text in-between will vary. I also do not want it to
replace all letter A's with quotes. I have tried a find
and replace many different ways and even tried finding the
WP Typographical symbol before I pasted unformatted text
and it wouldn't work.

I tired:

[A]*[\@]

It selects all the text prior to the @...I only want the A
if it falls in the scenario above or the @ if the same is
true...in order to change those characters to quotes.
If I search independently by [A]? it would also include
the ? character....so I wouldn't be able to replace just
the A.

Any suggestions would be greatly appreciated!
Kerri

Steve Lang

unread,
May 5, 2003, 7:51:31 PM5/5/03
to
Hi Kerri,

Was wondering if the A, @ and = after conversion have a different Unicode
value than the typical typographical set. To find out, open the highlight
one of the symbols, open Visual basic Environment, and type (without quotes)
"?AscW(selection)" and press return. If you get a 4 digit number (instead of
65 for A, 64 for @ and 61 for =), you may be able to do your search and
replace with the code instead of the textual equivalent of the code.

HTH and have a great day.

Steve

"kerri" <jkbou...@att.net> wrote in message
news:05f201c31349$dc85ea50$3401...@phx.gbl...

Klaus Linke

unread,
May 5, 2003, 11:26:17 PM5/5/03
to
Hi Kerri, hi Steve,

I'm pretty sure they'll be regular "A"s and "@"s. You might check if the
threads
http://www.google.de/groups?selm=207401c2ef33$6b3fd070$a301...@phx.gbl
http://www.google.de/groups?selm=a2l6jp$16c$03$1...@news.t-online.com
help you to convert them to real smart quotes.

Kerri, if the macro in the second thread doesn't work, you could send me a
sample document from WP (as an attachment to a private email), and I'd try
to make it work (...it might take a couple of days though).

Regards,
Klaus

Kerri

unread,
May 8, 2003, 7:08:01 PM5/8/03
to
Hi Steve, hi Klaus;

Steve, I was unable to get the code you provided to work
for me. I wasn't sure if it would display on screen or
Print out. But nothing worked....which means it must be
me.

Klaus, I reviewed the articles you mentioned and tried the
macro you provided. It looks like it is working but in
the end nothing was changed. (I will send the document to
you)

The first question would be....Should I be running the
macro in the document prior to "Paste unformatted" or
after. Once you Paste Unformatted that is when I get the
A and @. Otherwise Word will convert the WP file
fine......the reason I have to Paste Unformatted is to
remove all the "junk coded" from WP so the users don't end
up with a corrupt document 9 documents down the line. I
did try it for both documents prior to clean and after
clean with no luck.

Note:
- I do have WP Typographical symbols on my PC and will
always have it until we decide to remove WP. I would
prefer to do the clean the symbols, then paste unformatted
after, if possible.
- Version is Word 2000.
- Documentes are from WP 6.1 or older.

Thank you both for taking the time to help me resolve this
issue. I'm not sure why Word doesn't make it easier to
convert files from WordPerfect.

Thank you again.
Kerri


>-----Original Message-----
>Hi Kerri, hi Steve,
>
>I'm pretty sure they'll be regular "A"s and "@"s. You
might check if the
>threads
>http://www.google.de/groups?selm=207401c2ef33$6b3fd070
$a301...@phx.gbl

>http://www.google.de/groups?selm=a2l6jp$16c$03$1@news.t-

>.
>

Steve Lang

unread,
May 9, 2003, 11:23:58 AM5/9/03
to
Kerri,
I apologize. I neglected to mention that you needed to type that in the
immediate window and press the enter key.

Steve

"Kerri" <jkbou...@att.net> wrote in message
news:074801c315b6$ac53cc70$3301...@phx.gbl...

Kerri

unread,
May 9, 2003, 2:57:12 PM5/9/03
to
Thank you Steve for clarifying that. I ran the code and
the number was 65.

>.
>

Klaus Linke

unread,
May 9, 2003, 3:30:07 PM5/9/03
to
Hi Kerry,

I should have realized that "WP TypographicSymbols" would be a decorative
font, and those are notoriously hard to find/replace.
(Since Word can't figure out the (Uni)code for characters from those
fonts -- in fact, the symbols don't even necessarily appear in the Unicode
standard --, Word puts them in a special reserved block of codes, starting
at U+F000)

In the original macro, you would need only to change one line:

Select Case Asc(WPChar)
to
Select Case (AscW(WPChar) And &HFFFF&) - &HF000&


But the original macro would also only search the current StoryRange (the
main document if the cursor was in the main content, or the footnotes if it
was in the footnote pane ...).

And then, there was a wrong line continuation in a status bar message (the
two lines that would appear in red starting with "StatusBar = ...).

So I post the revised macro below (really a couple of macros and a
function; but you would only run WPTypoToUnicode.
It now should replace "WP TypographicSymbols" in all Story Ranges
(comments, endnotes, text boxes ...).
You would have to run it on the WP document *before* you save (or
copy/paste) as unformatted text.


Hope it works now,
Klaus

Sub WPTypoToUnicode()
Dim rngOld As Range
Set rngOld = Selection.Range.Duplicate
LoopStoryRanges "WPT2U"
rngOld.Select
StatusBar = "Finished changing ""WP " _
& "TypographicSymbols"" font to Unicode"
End Sub

Sub WPT2U(rngCurrent As Range)
Dim WPTypoChar As String
Dim rngReplace As Range
Dim RepChar As String
Set rngReplace = rngCurrent.Duplicate
rngReplace.Collapse (wdCollapseStart)
Do
With rngReplace.Find
.ClearFormatting
.Font.Name = "WP TypographicSymbols"
.Text = "^?"
.Forward = True
.Wrap = wdFindStop
.Format = True
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
End With
If rngReplace.Find.Execute Then
WPTypoChar = rngReplace.Text
rngReplace.Collapse (wdCollapseEnd)
RepChar = WPTypo2UniChar(WPTypoChar)
If RepChar <> "" Then
rngReplace.Find.ClearFormatting
rngReplace.Find.Replacement.ClearFormatting

With rngReplace.Find
.Replacement.Font.Name = _
ActiveDocument.Styles(wdStyleDefaultParagraphFont).Font.Name
.Font.Name = "WP TypographicSymbols"
.Text = WPTypoChar
.Replacement.Text = RepChar
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.Execute Replace:=wdReplaceAll
End With
End If
Else
Exit Do
' You might add a warning
End If
Loop
End Sub

Function WPTypo2UniChar(WPChar As String) As String
Dim RepFont As String
Dim RepChar As String
RepChar = ""
' some characters in this font don't have a proper or unambiguous
' Unicode representation; this list was done by hand
Select Case (AscW(WPChar) And &HFFFF&) - &HF000&
Case &H24 ' filled round bullet (small)
RepChar = ChrW(&H2022)
Case &H21 ' filled round bullet (medium)
RepChar = ChrW(&H25CF)
Case &H4D ' filled round bullet (large)
RepChar = ChrW(&H25CF)
Case &H50 ' filled square bullet (small)
RepChar = ChrW(&H25A0)
Case &H23 ' filled square bullet (medium)
RepChar = ChrW(&H25A0)
Case &H4F ' Large filled square bullet (large)
RepChar = ChrW(&H2580)
Case &H52 ' empty square bullet (small)
RepChar = ChrW(&H25A1)
Case &H51 ' empty square bullet (medium)
RepChar = ChrW(&H25A1)
Case &H4E ' circle (small)
RepChar = ChrW(&HB0)
Case &H22 ' circle (medium)
RepChar = ChrW(&H25CB)
Case &H25 ' star
RepChar = ChrW(&H2A)
Case &H26 ' Paragraph sign
RepChar = ChrW(&HB6)
Case &H27 ' Section sign
RepChar = ChrW(&HA7)
Case &H2A ' left pointing guillemet
RepChar = ChrW(&HAB)
Case &H2B ' right pointing guillemet
RepChar = ChrW(&HBB)
Case &H3C ' single opening quote
RepChar = ChrW(&H201B)
Case &H3D ' single high comma quote
RepChar = ChrW(&H2019)
Case &H3E ' single high turned comma quote
RepChar = ChrW(&H2018)
Case &H40 ' double high comma quote
RepChar = ChrW(&H201D)
Case &H41 ' double high turned comma quote
RepChar = ChrW(&H201C)
Case &H44 ' Left pointing single guillemet
RepChar = ChrW(&H2039)
Case &H45 ' Right pointing single guillemet
RepChar = ChrW(&H203A)
Case &H5F ' low single comma quote
RepChar = ChrW(&H201A)
Case &H60 ' low double comma quote
RepChar = ChrW(&H201E)
Case &H28 ' Spanish exclamation mark
RepChar = ChrW(&HA1)
Case &H29 ' Spanish question mark
RepChar = ChrW(&HBF)
Case &H30 ' feminine ordinal indicator (Spanish)
RepChar = ChrW(&HAA)
Case &H31 ' masculine ordinal indicator (Spanish)
RepChar = ChrW(&HBA)
Case &H32 ' 1/2
RepChar = ChrW(&HBD)
Case &H33 ' 1/4
RepChar = ChrW(&HBC)
Case &H3A ' 3/4
RepChar = ChrW(&HBE)
Case &H61 ' 1/3
RepChar = ChrW(&H2153)
Case &H62 ' 2/3
RepChar = ChrW(&H2154)
Case &H63 ' 1/8
RepChar = ChrW(&H215B)
Case &H64 ' 3/8
RepChar = ChrW(&H215C)
Case &H65 ' 5/8
RepChar = ChrW(&H215D)
Case &H66 ' 7/8
RepChar = ChrW(&H215E)
Case &H6F ' superscript 1
RepChar = ChrW(&HB9)
Case &H35 ' superscript 2
RepChar = ChrW(&HB2)
Case &H3B ' superscript 3
RepChar = ChrW(&HB3)
Case &H36 ' superscript n
RepChar = ChrW(&H207F)
Case &H37 ' Registered sign
RepChar = ChrW(&HAE)
Case &H38 ' Copyright sign
RepChar = ChrW(&HA9)
Case &H42 ' En dash
RepChar = ChrW(&H2013)
Case &H53 ' En dash
RepChar = ChrW(&H2013)
Case &H6E ' En dash
RepChar = ChrW(&H2013)
Case &H43 ' Em dash
RepChar = ChrW(&H2014)
Case &H48 ' Dagger
RepChar = ChrW(&H2020)
Case &H49 ' Double Dagger
RepChar = ChrW(&H2021)
Case &H4A ' Trademark sign
RepChar = ChrW(&H2122)
Case &H57 ' Ligature fi
RepChar = ChrW(&HFB01)
Case &H58 ' Ligature fl
RepChar = ChrW(&HFB02)
Case &H59 ' Ellipsis = ...
RepChar = ChrW(&H2026)
Case &H6A ' Care of
RepChar = ChrW(&H2105)
Case &H6C ' Per thousand
RepChar = ChrW(&H2030)
Case &H6D ' Numero sign
RepChar = ChrW(&H2116)
Case &H39 ' Currency sign
RepChar = ChrW(&HA4)
Case &H5A ' Dollar sign
RepChar = ChrW(&H24)
Case &H2C ' Pound sign
RepChar = ChrW(&HA3)
Case &H2D ' Yen sign
RepChar = ChrW(&HA5)
Case &H2E ' Peseta sign
RepChar = ChrW(&H20A7)
Case &H2F ' Florin sign (Dutch)
RepChar = ChrW(&H192)
Case &H34 ' Cent sign
RepChar = ChrW(&HA2)
Case &H5B ' Franc sign
RepChar = ChrW(&H20A3)
Case &H5E ' Lira sign
RepChar = ChrW(&H20A4)
Case &H69 ' Euro sign
RepChar = ChrW(&H20AC)
Case &H2C6 ' New Shequel sign (Israel)
RepChar = ChrW(&H20AA)
End Select
WPTypo2UniChar = RepChar
End Function

Private Sub LoopStoryRanges(myMacro As String)
Dim myStoryRange As Range
For Each myStoryRange In ActiveDocument.StoryRanges
Application.Run myMacro, myStoryRange
While Not (myStoryRange.NextStoryRange Is Nothing)
Set myStoryRange = myStoryRange.NextStoryRange
Application.Run myMacro, myStoryRange
Wend
Next myStoryRange
End Sub

Kerri

unread,
May 14, 2003, 4:46:30 PM5/14/03
to
THANK YOU !!! That worked beautifully!! This will make
it much easier for converting documents from WP to Word.
I don't know why Microsoft doesn't include something like
this automatically.

Thank you Klaus for taking the time to help!
Kerri

>.
>

Klaus Linke

unread,
May 15, 2003, 6:11:09 AM5/15/03
to
Glad it works now!

And thanks for sending me the sample doc. Without it, I couldn't have
finally fixed the macro.

Klaus

Reply all
Reply to author
Forward
0 new messages