We help IT Professionals succeed at work.

vb script insert table row before current row

Keith McElroy
on
How do I insert a row before the third row of a multi row Microsoft Word Table using VB Script  (not VBA)        

Here is my code and errl
dim tbl
set tbl = wd.ActiveDocument.Tables(1)                        
set newrow = tbl.rows.add(3)

Error:  http://www.screencast.com/t/mV9EUiu03
Comment
Watch Question

Bill PrewTest your restores, not your backups...
Expert of the Year 2019
Top Expert 2016

Commented:
Which of these lines is line 86?

~bp
Test your restores, not your backups...
Expert of the Year 2019
Top Expert 2016
Commented:
Try this, the documentation indicates the BeforeRow parm needs to be passed as a Row datatype, not a number.

set newrow = tbl.rows.add(tbl.Rows(3))

Open in new window

~bp
GrahamSkanRetired
Top Expert 2012

Commented:
Note that for most things, once the environment is established (Word Application object and/or Word Documentation object etc.,  VBScript and VBA are the same.

(Follow Bill Prew for the actual solution)