reverse fraction character

J

Janette

I have searched the database for an answer to this, but haven't come up with
a solution. Here's what I need. I have a gal in our office who recieves
Word documents that have fractions (characters-the little ones) inside her
document. She needs to find all the fractions and then replace them with the
text fraction (larger one before it gets transposed to the smaller one). She
can do a find and replace if she selects the fraction first, pastes it into
the find and replace box and then types in the same fraction as text into the
Replace box; however, this isn't efficient seeing that she may miss a
fraction or two. It is important that she replaces every fraction within the
document before she paste's this into another program. If she misses one
fraction, the other program blows up and work is lost. Any ideas on how she
can reverse the fraction back to normal text, and is there a way to search
the small fractions? She has tried searching for the / slash, but since Word
looks at this as one character, it does not notice the / mark.
Thanks, Janette
 
L

Lene Fredborg

Are the fractions to be changed only 1/4, 1/2 and 3/4?
Those fractions exist as special fraction characters. If you have AutoFormat
set to change fractions to fraction characters, the 3 characters of those
fractions are converted to the relevant fraction character. The ASCII values
of those characters are 188, 189 and 190. You can use find and replace to
search for each of the three fraction characters and replace with the
3-character fraction (in the Find what filed, type ^0 in front of the
character number, e.g. ^0188). Alternatively, you can use a macro that makes
all the replacements in one operation. The following macro finds the fraction
characters and replaces them with 1/4, 1/2 and 3/4:

Sub ConvertFractionsToNormalText()

Dim oArray1 As Variant
Dim oArray2 As Variant
Dim n As Long

'¼: chr(188), ½: chr(189), ¾: chr(190)

'Array of the fraction characters to search for
oArray1 = Array("^0188", "^0189", "^0190")
'Values to use as replacement
oArray2 = Array("1/4", "1/2", "3/4")

For n = LBound(oArray1) To UBound(oArray1)
With ActiveDocument.Range.Find
.Text = oArray1(n)
.Replacement.Text = oArray2(n)
.Execute Replace:=wdReplaceAll
End With
Next n

End Sub


--
Regards
Lene Fredborg - Microsoft MVP (Word)
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word
 
L

Lene Fredborg

You are welcome. I am glad I could help.

--
Regards
Lene Fredborg - Microsoft MVP (Word)
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top