Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #5  
Old 01-12-2024, 06:42 PM
syl3786 syl3786 is offline Seeking guidance on using Word macros to find and replace Arabic numbers after indent Windows 10 Seeking guidance on using Word macros to find and replace Arabic numbers after indent Office 2019
Advanced Beginner
Seeking guidance on using Word macros to find and replace Arabic numbers after indent
 
Join Date: Jan 2023
Posts: 97
syl3786 is on a distinguished road
Default

Quote:
Originally Posted by vivka View Post
Hi! Here is a simple option. I used some ideas from a Guessed's code (https://www.msofficeforums.com/179302-post6.html). You can modifiy the code to meet your needs. Maybe someone can suggest something more elegant.
Code:
Sub Repl_Digits_If()
'In the selected range, replace all single digits that start
'specifically indented paragraphs with asterisks.

Dim oRng As range
Dim oPar As Paragraph
Dim arrText() As String
Dim oDgt As range

Application.ScreenUpdating = False
Set oRng = selection.range
arrText = Split("zero one two three four five six seven eight nine", " ")

    For Each oPar In oRng.Paragraphs
        If oPar.range.ParagraphFormat.FirstLineIndent >= 0.5 And _
            oPar.range.Characters(1) Like "[0-9]*" And _
            oPar.range.Characters(2) Like "[!0-9]*" Then
                Set oDgt = oPar.range.Characters(1)
                oDgt.text = arrText(oDgt.text)
                oDgt.Font.ColorIndex = wdBrightGreen
        End If
    Next oPar
Application.ScreenUpdating = True
Set oRng = Nothing
End Sub
Thank you very much for your assistance. I have tested it and observed that the program only modifies the numbers "1" to "one" and "9" to "nine" if they appear in a document after identification of all numbers from 1 to 9.

The issue with the provided code is that it attempts to access array elements using the value of oDgt.Text, which is a string representing a single character. However, the Split function used to populate the arrText array expects a full string as input, not just a single character. As a result, the code is not able to correctly replace the digits with their corresponding words.
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Seeking guidance on using Word macros to find and replace Arabic numbers after indent Potential Clashes in Macros - Seeking Assistance yanyan9896 Word VBA 2 10-09-2023 04:59 AM
Find/replace - symbol for all numbers or symbol letters (Word 97) Genericname1111 Word 10 11-10-2019 10:37 PM
Seeking guidance on using Word macros to find and replace Arabic numbers after indent Find and Replace Numbers Macro VBA in Microsoft Word Yotem189 Word VBA 3 09-20-2018 05:55 AM
Numbers format in word to arabic Mzbarca Word 1 02-28-2016 07:56 PM
Find and replace BETWEEN numbers WordUser2015 Word 4 12-19-2014 02:09 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:02 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft