MS Word 2002 - VB.NET - Borders Problem

  • Thread starter Thread starter ivanovick
  • Start date Start date
I

ivanovick

Hello,

I'm currently developing with Visual Studio.NET 2003, Office 2002 and
VB.NET. I'm creating a Word Document and in the document is a table
named EasyTable. I'm trying to create borders on the top and bottom of
the first row. Here's the problem:

This code works:

With EachTable.Rows(1)
With .Borders.Item(wdBorderBottom)
.LineStyle = Word.WdLineStyle.wdLineStyleSingle
.LineWidth = Word.WdLineWidth.wdLineWidth050pt
End With
End With

Whereas this code does not:

With EachTable.Rows(1)
With .Borders.Item(wdBorderTop)
.LineStyle = Word.WdLineStyle.wdLineStyleSingle
.LineWidth = Word.WdLineWidth.wdLineWidth050pt
End With
End With

Whenever the line ".Borders.Item(wdBorderBottom)" is changed to
wdBorderTop, wdBorderHorizontal or any of the other available values, I
get the following error: "One of the values passed to this method or
property is out of range."

And yet, the problem is reversed when it comes to the last row. This
code works:

With EachTable.Rows.Last
'Works
With .Borders.Item(wdBorderTop)
.LineStyle = Word.WdLineStyle.wdLineStyleSingle
.LineWidth = Word.WdLineWidth.wdLineWidth050pt
End With
End With

But the rest of the values don't.

Any assistance is appreciated. Thanks.
 
Back
Top