Forum Discussion
Numbering with Gujarati Numbers.
- Mar 20, 2023
mehulchanpura Unfortunately, all that I can suggest is that you request the facility be added via the Feedback facility under Help. While that may not help you with the current book, such numbering might be available for a future book.
In the meantime, if you used one of the available numbering systems and then set up an Excel workbook with those numbers in Column A of Sheet 1 and the corresponding Gujarati numbers in Column B and then when finished your book you ran a macro containing the following code, it will ask you to select the workbook containing the numbers and then replace the numbers used in the document with their Gujarati equivalents. (I would suggest running it on a copy of the document so that your original remains intact, just in case the result is not as expected).
Dim FD As FileDialog Dim strWorkbook As String Set FD = Application.FileDialog(msoFileDialogFilePicker) With FD .Title = "Select the Workbook containing the numbers." .Filters.Clear .Filters.Add "Excel Files", "*.xlsx" .AllowMultiSelect = False If .Show = -1 Then strWorkbook = .SelectedItems(1) Else MsgBox "You did not select a file." Exit Sub End If End With Dim xlapp As Object Dim xlbook As Object Dim xlsheet As Object Dim myarray As Variant On Error Resume Next Set xlapp = GetObject(, "Excel.Application") If Err Then bstartApp = True Set xlapp = CreateObject("Excel.Application") End If On Error GoTo 0 Set xlbook = xlapp.Workbooks.Open(strWorkbook) Set xlsheet = xlbook.Worksheets(1) myarray = xlsheet.Range("A1").CurrentRegion.Value xlbook.Close If bstartApp = True Then xlapp.Quit End If Set xlapp = Nothing Set xlbook = Nothing Set xlsheet = Nothing ActiveDocument.ConvertNumbersToText For i = 2 To UBound(myarray) Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find .Text = myarray(i, 1) .Replacement.Text = myarray(i, 2) .MatchWildcards = False .Wrap = wdFindContinue .MatchCase = False End With Selection.Find.Execute Replace:=wdReplaceAll Next i
mehulchanpura Unfortunately, all that I can suggest is that you request the facility be added via the Feedback facility under Help. While that may not help you with the current book, such numbering might be available for a future book.
In the meantime, if you used one of the available numbering systems and then set up an Excel workbook with those numbers in Column A of Sheet 1 and the corresponding Gujarati numbers in Column B and then when finished your book you ran a macro containing the following code, it will ask you to select the workbook containing the numbers and then replace the numbers used in the document with their Gujarati equivalents. (I would suggest running it on a copy of the document so that your original remains intact, just in case the result is not as expected).
Dim FD As FileDialog
Dim strWorkbook As String
Set FD = Application.FileDialog(msoFileDialogFilePicker)
With FD
.Title = "Select the Workbook containing the numbers."
.Filters.Clear
.Filters.Add "Excel Files", "*.xlsx"
.AllowMultiSelect = False
If .Show = -1 Then
strWorkbook = .SelectedItems(1)
Else
MsgBox "You did not select a file."
Exit Sub
End If
End With
Dim xlapp As Object
Dim xlbook As Object
Dim xlsheet As Object
Dim myarray As Variant
On Error Resume Next
Set xlapp = GetObject(, "Excel.Application")
If Err Then
bstartApp = True
Set xlapp = CreateObject("Excel.Application")
End If
On Error GoTo 0
Set xlbook = xlapp.Workbooks.Open(strWorkbook)
Set xlsheet = xlbook.Worksheets(1)
myarray = xlsheet.Range("A1").CurrentRegion.Value
xlbook.Close
If bstartApp = True Then
xlapp.Quit
End If
Set xlapp = Nothing
Set xlbook = Nothing
Set xlsheet = Nothing
ActiveDocument.ConvertNumbersToText
For i = 2 To UBound(myarray)
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
.Text = myarray(i, 1)
.Replacement.Text = myarray(i, 2)
.MatchWildcards = False
.Wrap = wdFindContinue
.MatchCase = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Next i
- mehulchanpuraMar 21, 2023Copper Contributor
Thank you Doug Robbins for your suggestion but when I try to create above Macro in my word document, I got this error.Error
- Mar 21, 2023
mehulchanpura You need to put the code inside a Sub()- End Sub construction such as
Sub InsertGujaratiNumbers()
' Paste the code here
End Sub
- mehulchanpuraMar 22, 2023Copper ContributorThank you Doug Robbins. After above correction your code is working fine, and thanks a lot for your help. Your idea will help me for small book, but recently I am working on a book which have more than 700 pages and lots of numbering everywhere, so replacing English number to Gujarati number is also very time consuming for me even if I use Find & Replace option.
But as you suggest first i will backup my file and then sure I will try your idea.
Thanks for your time.
Thank you very much.