Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 01-12-2024, 12:30 AM
vivka vivka is offline Seeking guidance on using Word macros to find and replace Arabic numbers after indent Windows 7 64bit Seeking guidance on using Word macros to find and replace Arabic numbers after indent Office 2016
Expert
 
Join Date: Jul 2023
Posts: 302
vivka is on a distinguished road
Default

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
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
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 07:05 AM.


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