Home |
Search |
Today's Posts |
#1
![]() |
|||
|
|||
![]()
Hi,
In my MS Word document, there are about 50 pages. I need to add "0" where decimal value is in this format .25 or any Number. I need VBA code. I have tried with below, but it is time consuming is there other way of doing same. Sub a() With ActiveDocument For i = 1 To .Words.Count If .Words(i).Text = "." Then If IsNumeric(.Words(i).Text & .Words(i + 1).Text) And .Words(i - 1).Text "0" Then .Words(i).Text = "0" & .Words(i).Text i = i + 2 End If End If Next End With End Sub Thanks in advance Regards, Sudhir. |
#2
![]()
Posted to microsoft.public.word.formatting.longdocs
|
|||
|
|||
![]()
A wildcard search should do the trick. There might be more efficient
ways, but here's one attempt: "Find what": ([!0-9])(.)([0-9]) "Replace with": 0\2\3 (Note that I have entered a space before the zero in the "Replace with" box.) Test it on a *copy* of your document. Stefan Blom Microsoft Word MVP On 2012-06-05 06:54, Sudhir_Gawade wrote: Hi, In my MS Word document, there are about 50 pages. I need to add "0" where decimal value is in this format .25 or any Number. I need VBA code. I have tried with below, but it is time consuming is there other way of doing same. Sub a() With ActiveDocument For i = 1 To .Words.Count If .Words(i).Text = "." Then If IsNumeric(.Words(i).Text & .Words(i + 1).Text) And .Words(i - 1).Text "0" Then .Words(i).Text = "0" & .Words(i).Text i = i + 2 End If End If Next End With End Sub Thanks in advance Regards, Sudhir. |
#3
![]()
Posted to microsoft.public.word.formatting.longdocs
|
|||
|
|||
![]()
Thinking about it, the character before the period is a space, so you
should be able to do it more easily as follows: "Find what": ( )(.)([0-9]) "Replace with": 0\2\3 (Again, there is a space before the zero in "Replace with.") Stefan Blom Microsoft Word MVP On 2012-06-06 13:17, Stefan Blom wrote: A wildcard search should do the trick. There might be more efficient ways, but here's one attempt: "Find what": ([!0-9])(.)([0-9]) "Replace with": 0\2\3 (Note that I have entered a space before the zero in the "Replace with" box.) Test it on a *copy* of your document. Stefan Blom Microsoft Word MVP On 2012-06-05 06:54, Sudhir_Gawade wrote: Hi, In my MS Word document, there are about 50 pages. I need to add "0" where decimal value is in this format .25 or any Number. I need VBA code. I have tried with below, but it is time consuming is there other way of doing same. Sub a() With ActiveDocument For i = 1 To .Words.Count If .Words(i).Text = "." Then If IsNumeric(.Words(i).Text & .Words(i + 1).Text) And .Words(i - 1).Text "0" Then .Words(i).Text = "0" & .Words(i).Text i = i + 2 End If End If Next End With End Sub Thanks in advance Regards, Sudhir. |
#4
![]() |
|||
|
|||
![]()
Hi Stefan,
Thanks for your reply. Sudhir Gawade. Quote:
|
Reply |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
align numbers by decimal point | Tables | |||
decimal point | Tables | |||
Getting Decimal Point With Mail Merge | Mailmerge | |||
Decimal Point alignment | Tables | |||
Change a decimal point (.) by coma (,) | Mailmerge |