Results 1 to 8 of 8

Thread: Add dashes between letters

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #5
    Quote Originally Posted by Kindyr View Post
    I am trying to make macro to add dashes between all the letters in a word. I want to have names be spelled out with dashes between them. I do not want the name to be automatically upper case.
    Try the following. Put the cursor in the word and run the macro

    Sub Macro1()
    Dim orng As Range
    Dim i As Integer
    Set orng = Selection.Words(1)
    orng.MoveEndWhile Chr(32) & Chr(45), wdBackward
    For i = orng.Characters.Count - 1 To 1 Step -1
        orng.Characters(i).InsertAfter Chr(45)
    Next i
    Set orng = Nothing
    End Sub
    Last edited by Aussiebear; 07-08-2025 at 06:34 PM.
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •