View Single Post
 
Old 01-09-2014, 02:54 PM
macropod's Avatar
macropod macropod is offline Windows 7 32bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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

You can use code like the following to convert a selected number to Hindi script.
Code:
Sub ArabicToHindi()
Application.ScreenUpdating = False
Dim fRng As Range, StrTmp As String, i As Long
Set fRng = Selection.Range
With Selection.Range
  .Collapse wdCollapseStart
  With .Find
    .ClearFormatting
    .Forward = True
    .Wrap = wdFindStop
    .Format = False
    .MatchWildcards = True
    .Text = "<[,.0-9]{1,}"
    .Replacement.Text = ""
    .Execute
  End With
  Do While .Find.Found
    MsgBox fRng.Start & vbTab & fRng.End _
    & vbCr & .Start & vbTab & .End
    If .InRange(fRng) = False Then Exit Do
    With .Duplicate
      If .Characters.Last = "." Then .End = .End - 1
      If .Characters.Last = "," Then .End = .End - 1
      ' If the numbers are input right-to-left, use:
      StrTmp = Reverse(.Text)
      ' If the numbers are input left-to-right, use:
      'StrTmp = .Text
      For i = 0 To 9
        StrTmp = Replace(StrTmp, Chr(48 + i), ChrW(1632 + i))
      Next i
      .Text = StrTmp
      'apply Hindi proofing language
      .LanguageID = wdHindi
    End With
    .Collapse (wdCollapseEnd)
    .Find.Execute
  Loop
End With
fRng.Select
Application.ScreenUpdating = False
End Sub
 
Function Reverse(StrTmp As String) As String
  If (Len(StrTmp) > 1) Then
    Reverse = Reverse(Mid$(StrTmp, 2)) + Left$(StrTmp, 1)
  Else
    Reverse = StrTmp
  End If
End Function
The code includes a function for reversing the number too, if that's what you need. Comments in the code show what to change.

Since your numbers are in the page header, you'll have to select them there before running the macro. I also note that your '71002' is a field code. The macro will convert that to plain text.

For macro installation & usage instructions, see: http://www.gmayor.com/installing_macro.htm
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote