TeDeSm
asked on
How to set borders in a Word table
I am porting over some code from VBA to VB.Net in a VS2008 project.
I am automating a Word 2007 document where a table is inserted and then adding rows as required. Each row added is to have a dotted line underneath. The attached code is from VBA but VS complains of (wdBorderBottom). What would the correct syntax be please?
I had thought it would be like below, but that syntax throws an exception.
.Tables(1).Rows(r).Borders ("wdBorder Bottom").L ineStyle = Word.WdLineStyle.wdLineSty leDot
I am automating a Word 2007 document where a table is inserted and then adding rows as required. Each row added is to have a dotted line underneath. The attached code is from VBA but VS complains of (wdBorderBottom). What would the correct syntax be please?
I had thought it would be like below, but that syntax throws an exception.
.Tables(1).Rows(r).Borders
With objWord.ActiveDocument
.Tables(1).Rows(I).Select
.Tables(1).Rows(i).Borders(wdBorderBottom).LineStyle = wdLineStyleDot
.ActiveWindow.Selection.InsertRowsBelow
End With
You can also try:
Selection.InsertRowsBelow 1
With Selection.Cells
With .Borders(wdBorderBottom)
.LineStyle = wdLineStyleDot
End With
End With
ASKER
Chris,
Can't seem to get that syntax to work within my table as wdBorderType.wdBorderBotto m appears to be read only.
Regards
Can't seem to get that syntax to work within my table as wdBorderType.wdBorderBotto
Regards
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
What syntax did you use .. it replaces wdBorderBottom therefore:
Chris
Chris
With objWord.ActiveDocument
.Tables(1).Rows(I).Select
.Tables(1).Rows(i).Borders(wdBorderType.wdBorderBottom ).LineStyle = wdLineStyleDot
.ActiveWindow.Selection.InsertRowsBelow
End With
ASKER
Spot on, I was so nearly there at one time but missed it.
Good solution.
Good solution.
ASKER
Hi Chris,
Needed the Word. reference included.
Thanks
Needed the Word. reference included.
Thanks
Not happy !
You asked "attached code is from VBA but VS complains of (wdBorderBottom). What would the correct syntax be please?"
The correct syntax I gave you as Word.WdBorderType.wdBorder Bottom and although in my last post I overlooked a fiull paste in your code I did post the syntax for the question as posted in that first post
Chris
You asked "attached code is from VBA but VS complains of (wdBorderBottom). What would the correct syntax be please?"
The correct syntax I gave you as Word.WdBorderType.wdBorder
Chris
Word.WdBorderType.wdBorder
Chris