View Single Post
 
Old 01-29-2012, 11:41 AM
Jennifer Murphy's Avatar
Jennifer Murphy Jennifer Murphy is offline Windows XP Office 2007
Competent Performer
 
Join Date: Aug 2011
Location: Silicon Valley
Posts: 234
Jennifer Murphy is on a distinguished road
Default

I am making progress, but have run into a couple of puzzling results.

I wanted to use this same syntax to change the font and the borders. I started by capturing the code using the recorder. This is what I got:

Code:
Sub Macro1()
  Selection.Font.Name = "Calibri"
  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
End Sub
Then I tried to adapt it to my macro.

For the font change line, I got a Compile error: "Methor or data member not found".

For the last two lines of the border settings, I got a Runtime error '5941': "The requested member of the collection does not exist".

These lines are shown in red and commented out.

Code:
With Selection.Tables(1)
  .Rows.AllowBreakAcrossPages = False
  .AllowAutoFit = False
  .Rows(1).HeadingFormat = SettingHeaderRow
'  .Font.Name = "Calibri"
  If SettingHeaderBorderOff Then  'Turn all but bottom border off
    With Selection.Tables(1).Rows(1)
      .Borders(wdBorderTop).LineStyle = wdLineStyleNone
      .Borders(wdBorderLeft).LineStyle = wdLineStyleNone
      .Borders(wdBorderRight).LineStyle = wdLineStyleNone
      .Borders(wdBorderVertical).LineStyle = wdLineStyleNone
'      .Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone
'      .Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleNone
    End With
  End If
End With
What am I doing wrong?
Reply With Quote