Change Word page numbers into foreign language numerals.

A

amha

I have a document in Word created with Ethiopian language fonts. I would like
to change the page numbers into Ethiopian numerals. All the numbers in the
manuscript are between 1-2000. I can build a look uo table. Is there a way to
serach for page numbers and replace them with the character's in the look up
table??
 
K

Klaus Linke

Maybe you can adapt this. The macro assumes the page numbers are in the
built-in "Page Number" character style, and you replace them with your own
"EthiopianNumber" character style, which sets your Ethiopian font.
It uses a wildcard Find to match (arab) numbers, and assumes they're all
below 2000, or you'll get an error message when replacing.

Dim i As Long
Dim a(1, 2000) ' your lookup table
For i = 0 To 2000
a(0, i) = Trim(STR(i))
' store the ethiopian number in a(1,i), instead of the next line:
a(1, i) = Trim(STR(2 * i))
Next i
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
Selection.Find.Style = ActiveDocument.Styles(wdStylePageNumber)
Do
With Selection.Find
.Text = "[0-9]{1;}"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchWildcards = True
End With
If Selection.Find.Execute Then
Selection.Style = ActiveDocument.Styles("EthiopianNumber")
Selection.Text = a(1, Val(Selection.Text))
Else
MsgBox "Done", vbInformation
Exit Sub
End If
Loop

Regards,
Klaus
 
P

Peter Jamieson

If Ethiopian numerals the ones where you have different characters for
1-10,20,30,...,90,100 and so on, I think you will have a problem here if
your page numbers are inserted using { PAGE } fields in a header or footer,
because
a. you can't simply change the font of the { PAGE } field result using a
\*Charformat switch
b. unless every page is in a separate Word section, you won't be able to
replace the { PAGE } result by a different number on each page, because the
same header/footer is used for the whole section.

What you can do is
a. create Word Document variables with names such as

e1
e2
e3

and the corresponding strings required for the numerals
b. instead of PAGE fields, use the following nested fields:

{ DOCVARIABLE "e{ PAGE }" \*Charformat }
c. if necessary, format the D of Docvariable with the font you need to use

All the {} need to be the special field code braces you can insert using
ctrl-F9.

Also, you probably have many references to those page numbers - how to deal
with those probably depends on how you are making the references.

Peter Jamieson
 

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