locked
MS Word Macro - Reformatting Lists RRS feed

  • Question

  • Hello, 

    I am new to creating macros and would appreciate help with reformatting lists in Microsoft Word. Some brief background on the task I want to complete: 

    • Change list numbers--e.g., "1...2...3..."--to include the word "Slide" with the numbers. Also, bold the text and numbers. ("Slide 1," "Slide 2," etc.)
    • Move the text corresponding to each list number--e.g., "1. Colorado," "2. Arizona," etc.--below the list number.

    Currently, I use Adobe Captivate to generate a list of caption text that I would like a macro to automatically format. Below is what the initial output looks like, followed by how I would like it to appear after running the macro:

    Before Running the Macro

    1. Colorado

    2. Arizona

    After Running the Macro

    Slide 1

    Colorado

    Slide 2

    Arizona

    Any help would be much appreciated. Thanks!

    Saturday, May 10, 2014 7:10 PM

All replies

  • The only reliable way is to create a style and apply the style to the lists.

    There are two fantastic sites for all Word technical stuff like this:

    http://word.mvps.org/FAQs/Numbering.htm

    http://shaunakelly.com/word/numbering/outlinenumbering.html

    Digest everything in those sites to learn a lot more about Word and how to drive it well. Styles are the key, just formatting manually (or using VBA to format each list) will probably only bring about confusion and grief.


    Rod Gill
    Author of the one and only Project VBA Book
    www.project-systems.co.nz

    Saturday, May 10, 2014 10:52 PM
  • Dear Rod, 

    Thank you for your response. I'll definitely follow your advice.

    Best, 

    Todd

    Sunday, May 11, 2014 6:32 PM
  • I am not convinced that you can achieve this effect with styles, at least not if you want automatic numbered styles.

    You could use a macro to split the paragraphs and replace the numbers with SEQ fields, or simply split the lines and keep the original numbers - maybe something like

    Sub FormatSlideList()
    Dim oPara As Paragraph
    Dim oRng As Range, oNext As Range
        For Each oPara In ActiveDocument.Content.Paragraphs
            If IsNumeric(oPara.Range.Characters(1)) = True Then
                Set oRng = oPara.Range
                With oRng
                    .End = .Start + InStr(1, oPara.Range, Chr(46)) - 1
                    oPara.Range = Replace(oPara.Range.FormattedText, Chr(46) & Chr(32), Chr(13))
                    .Text = vbNullString
                    .Fields.Add oRng, wdFieldSequence, "Slides\# ""0""", False
                    .InsertBefore "Slide "
                    .End = .Paragraphs(1).Range.End - 1
                    .Font.Bold = True
                    .Start = .End - 1
                    .Delete
                End With
            End If
        Next oPara
    End Sub


    Graham Mayor - Word MVP
    www.gmayor.com

    Tuesday, May 13, 2014 2:19 PM
  • Dear Graham, 

    Thank you, this is great. I've been struggling with styles over the past couple of days and can't find a way to automatically update the list. I don't think there is a way besides manually changing each list item. I'll follow your advice and try out your macro. 

    Thanks again. 

    Best, 

    Todd

    Wednesday, May 14, 2014 1:01 AM