question

KevinLossner-8449 avatar image
0 Votes"
KevinLossner-8449 asked Viorel-1 answered

How do I use VBScript to get the number of rows in a table in an RTF file?

I tried the following code, but an error results in the 6th line, indicating that an object is required.

     Set objFile = fso.GetFile(File)
      Set wrd = GetObject(, "Word.Application") 
      wrd.Visible = False 
      wrd.Documents.Open objFile.Path 
      Set oFile = wrd.ActiveDocument
      Set rowcount = oFile.Tables(1).Rows.Count
      WScript.Echo "The number of rows is " & rowcount

This is in a WSH *.vbs script in which an RTF file with a single table is chosen. I need to know the number of rows in that table so I can do some loops in particular cell ranges to update the content of that table.

windows-api
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Viorel-1 avatar image
0 Votes"
Viorel-1 answered

Try removing "Set" from sixth line.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.