Results 1 to 3 of 3
  1. #1
    WS Lounge VIP
    Join Date
    Mar 2006
    Location
    Maryland, USA
    Posts
    690
    Thanks
    17
    Thanked 66 Times in 56 Posts

    Need help with a recorded macro

    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
    Last edited by jscher2000; 2011-06-28 at 14:50. Reason: Added [code][/code] around code to improve formatting.

  2. #2
    Star Lounger
    Join Date
    Mar 2010
    Location
    Texas
    Posts
    54
    Thanks
    9
    Thanked 0 Times in 0 Posts
    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.

  3. #3
    WS Lounge VIP
    Join Date
    Mar 2006
    Location
    Maryland, USA
    Posts
    690
    Thanks
    17
    Thanked 66 Times in 56 Posts
    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

Posting Permissions

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