Search code examples
ms-wordvbscriptcell

Word VBS script add border cell


I have a simple VBS script below that opens Word and creates a table with 4 cells, I need to add a bottom border only for the cell with TEXT inside and not for the entire table, any ideas?

Set objWord = CreateObject("Word.Application")
objword.visible = true
Set objDoc = objWord.Documents.Add()
Set objSelection = objWord.Selection
Set objRange = objDoc.Range()
objDoc.Tables.Add objRange,2,2
Set objTable = objDoc.Tables(1)
objTable.Cell(2,1).Range.Font.Name = "Arial"
objTable.Cell(2,1).Range.Text = "TEXT"

Solution

  • objTable.Cell(2,1).Borders(-3).LineStyle = 1 'wdLineStyleSingle