Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 04-13-2019, 09:10 PM
gmayor's Avatar
gmayor gmayor is offline How to insert colon at the start of every indentation Windows 10 How to insert colon at the start of every indentation Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,144
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Based on insufficient information, the following will do what you ask. You will need to list the names used in the string strNames each separated by |. The code should only add the colons where they are not present (based on your message text). http://www.gmayor.com/installing_macro.htm
Code:
Sub AddColons()
Dim VName As Variant
Dim oRng As Range
Dim oRng2 As Range
Dim i As Long
Const strNames As String = "JOHN|JACK"
    VName = Split(strNames, "|")
    For i = 0 To UBound(VName)
        Set oRng = ActiveDocument.Range
        With oRng.Find
            Do While .Execute(FindText:=VName(i), MatchWildcards:=True)
                If oRng.Start = oRng.Paragraphs(1).Range.Start Then
                    Set oRng2 = oRng.Duplicate
                    oRng2.End = oRng2.End + 2
                    If Not oRng2.Characters.Last = ":" Then
                        oRng.InsertAfter " :"
                    End If
                    oRng.Collapse 0
                 End If
            Loop
        End With
    Next i
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
 

Tags
colon, indentation, insert



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to insert colon at the start of every indentation How remove colon ':' from my chapter references? peytontodd Word 7 10-25-2023 07:13 PM
Auto Capitalization After Colon lowens Word 1 04-28-2018 02:58 PM
How to insert colon at the start of every indentation The difference between a comma and colon when adding? Exhale Excel 8 03-23-2016 05:26 AM
How to insert colon at the start of every indentation Bullet Indentation Lost But Text Indentation Not Lost Trypsinogen Word 2 09-26-2013 02:01 PM
aligning colon JRaul Word 4 07-07-2012 06:06 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:38 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