![]() |
#1
|
||||
|
||||
![]() I want to add code to a macro to turn off all but the bottom border in the header row of a table. I started the macro recorder, selected the first row, turned off all borders, then turned the bottom border back on. Here's the code I got: Code:
Sub Macro1() Selection.Borders(wdBorderTop).LineStyle = wdLineStyleNone Selection.Borders(wdBorderLeft).LineStyle = wdLineStyleNone Selection.Borders(wdBorderBottom).LineStyle = wdLineStyleNone Selection.Borders(wdBorderRight).LineStyle = wdLineStyleNone Selection.Borders(wdBorderVertical).LineStyle = wdLineStyleNone Selection.Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone Selection.Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleNone With Selection.Borders(wdBorderBottom) .LineStyle = Options.DefaultBorderLineStyle .LineWidth = Options.DefaultBorderLineWidth .Color = Options.DefaultBorderColor End With End Sub |
#2
|
||||
|
||||
![]()
Hi Jennifer,
You could use a loop: Code:
Sub Demo() Dim i As Long With Selection.Tables(1) With .Rows(1).Range For i = 1 To .Borders.Count .Borders(i).LineStyle = wdLineStyleNone Next .Borders(wdBorderBottom).LineStyle = Options.DefaultBorderLineStyle End With End With End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
||||
|
||||
![]()
That's pretty clever. I never would have thought of that.
So I take it there is no wdBordersAll or something like that, right? ![]() |
#4
|
||||
|
||||
![]() Quote:
ActiveDocument.Tables(1).Rows(1).Borders.Enable = False but that would remove the bottom border from the row as well. You might remedy that with code like: Code:
With ActiveDocument.Tables(1) .Rows(1).Borders.Enable = False .Rows(2).Borders.Enable = True End With
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
![]() Quote:
If VBA was kept up with the .NET languages, you could do something like (I'm not familiar with VB .NET, so this is borrowing from the C# syntax) Code:
Selection.Borders.ForEach(x => x.LineStyle = wdLineStyleNone) |
#6
|
||||
|
||||
![]()
Yes, one could loop through the collection, but that still requires turning on/off seven separate border attributes.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
![]() |
Thread Tools | |
Display Modes | |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
m&co | Mail Merge | 3 | 01-06-2012 07:27 PM |
![]() |
tinfanide | Word VBA | 2 | 12-02-2011 05:53 AM |
Insert table button doesn't work in Outlook 2010 e-mail message | ironwoods | Outlook | 0 | 08-02-2010 12:24 PM |
Converting document to PDF but table of contents doesn't work | luthers | Word | 0 | 07-30-2009 03:29 PM |
IF statements that shifts to right. | kent | Excel | 0 | 01-19-2006 02:23 PM |