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("wdBorderBottom").LineStyle = Word.WdLineStyle.wdLineStyleDot
With objWord.ActiveDocument
.Tables(1).Rows(I).Select
.Tables(1).Rows(i).Borders(wdBorderBottom).LineStyle = wdLineStyleDot
.ActiveWindow.Selection.InsertRowsBelow
End With

Open in new window

TeDeSmAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Chris BottomleySoftware Quality Lead EngineerCommented:
Try:

Word.WdBorderType.wdBorderBottom

Chris
ydsonlineCommented:
You can also try:

Selection.InsertRowsBelow 1
    With Selection.Cells

        With .Borders(wdBorderBottom)
            .LineStyle = wdLineStyleDot
         End With
    End With

Open in new window

TeDeSmAuthor Commented:
Chris,
Can't seem to get that syntax to work within my table as wdBorderType.wdBorderBottom appears to be read only.
Regards
OWASP: Forgery and Phishing

Learn the techniques to avoid forgery and phishing attacks and the types of attacks an application or network may face.

irudykCommented:
Try entering the syntax as:
.Tables(1).Rows(r).Borders(Word.WdBorderType.wdBorderBottom).LineStyle = Word.WdLineStyle.wdLineStyleDot

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Chris BottomleySoftware Quality Lead EngineerCommented:
What syntax did you use .. it replaces wdBorderBottom therefore:

Chris
With objWord.ActiveDocument 
.Tables(1).Rows(I).Select 
.Tables(1).Rows(i).Borders(wdBorderType.wdBorderBottom ).LineStyle = wdLineStyleDot 
.ActiveWindow.Selection.InsertRowsBelow 
End With

Open in new window

TeDeSmAuthor Commented:
Spot on, I was so nearly there at one time but missed it.

Good solution.
TeDeSmAuthor Commented:
Hi Chris,
Needed the Word. reference included.
Thanks
Chris BottomleySoftware Quality Lead EngineerCommented:
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.wdBorderBottom 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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Word

From novice to tech pro — start learning today.