• Need help with a recorded macro

    Author
    Topic
    #477499

    Hi, folks,

    I just recorded a macro to color the borders of a table (below). And it is failing where I’ve indicated (see line with the asterisks). I am at a client site using W2007 on windows XP. In generating the macro, I just clicked the all borders icon. Can anyone tell me how to fix it?

    Code:
    Sub ResBrdrsColor()
    '
    ' ResBrdrsColor Macro
    '
    '
    Options.DefaultBorderColor = 12566463
    With Selection.Borders(wdBorderTop)
    .LineStyle = Options.DefaultBorderLineStyle
    .LineWidth = Options.DefaultBorderLineWidth
    .Color = Options.DefaultBorderColor
    End With
    With Selection.Borders(wdBorderLeft)
    .LineStyle = Options.DefaultBorderLineStyle
    .LineWidth = Options.DefaultBorderLineWidth
    .Color = Options.DefaultBorderColor
    End With
    With Selection.Borders(wdBorderBottom)
    .LineStyle = Options.DefaultBorderLineStyle
    .LineWidth = Options.DefaultBorderLineWidth
    .Color = Options.DefaultBorderColor
    End With
    With Selection.Borders(wdBorderRight)
    .LineStyle = Options.DefaultBorderLineStyle
    .LineWidth = Options.DefaultBorderLineWidth
    .Color = Options.DefaultBorderColor
    End With
    With Selection.Borders(wdBorderHorizontal)
    .LineStyle = Options.DefaultBorderLineStyle
    .LineWidth = Options.DefaultBorderLineWidth
    .Color = Options.DefaultBorderColor
    End With
    With Selection.Borders(wdBorderVertical)
    .LineStyle = Options.DefaultBorderLineStyle
    .LineWidth = Options.DefaultBorderLineWidth
    .Color = Options.DefaultBorderColor
    End With
    Selection.Borders(wdBorderTop).LineStyle = wdLineStyleNone
    Selection.Borders(wdBorderLeft).LineStyle = wdLineStyleNone
    Selection.Borders(wdBorderBottom).LineStyle = wdLineStyleNone
    Selection.Borders(wdBorderRight).LineStyle = wdLineStyleNone
    Selection.Borders(wdBorderHorizontal).LineStyle = wdLineStyleNone
    Selection.Borders(wdBorderVertical).LineStyle = wdLineStyleNone
    With Selection.Borders(wdBorderTop)
    .LineStyle = Options.DefaultBorderLineStyle
    .LineWidth = Options.DefaultBorderLineWidth
    .Color = Options.DefaultBorderColor
    End With
    With Selection.Borders(wdBorderLeft)
    .LineStyle = Options.DefaultBorderLineStyle
    .LineWidth = Options.DefaultBorderLineWidth
    .Color = Options.DefaultBorderColor
    End With
    With Selection.Borders(wdBorderBottom)
    .LineStyle = Options.DefaultBorderLineStyle
    .LineWidth = Options.DefaultBorderLineWidth
    .Color = Options.DefaultBorderColor
    End With
    With Selection.Borders(wdBorderRight)
    .LineStyle = Options.DefaultBorderLineStyle
    .LineWidth = Options.DefaultBorderLineWidth
    .Color = Options.DefaultBorderColor
    End With
    With Selection.Borders(wdBorderHorizontal)
    .LineStyle = Options.DefaultBorderLineStyle
    .LineWidth = Options.DefaultBorderLineWidth
    .Color = Options.DefaultBorderColor
    End With
    ***With Selection.Borders(wdBorderVertical)***
    .LineStyle = Options.DefaultBorderLineStyle
    .LineWidth = Options.DefaultBorderLineWidth
    .Color = Options.DefaultBorderColor
    End With
    End Sub
    Viewing 1 reply thread
    Author
    Replies
    • #1285831

      Delete that offending With section and the line “Selection.Borders(wdBorderVertical).LineStyle = wdLineStyleNone”.

      wdBorderVertical is modified three times. The two With sections changing it are identical (so only the first is needed). While the other line changes the LineStyle, it would have been changed back later. Therefore, the last two references aren’t needed.

    • #1285840

      Thanks so much. With your hint, I deleted all but the first set of instructions. Works fine now. Whew! one down 150 to go.

      Pam

    Viewing 1 reply thread
    Reply To: Need help with a recorded macro

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: