简体   繁体   中英

Vb.net how to get the index number of a word table

I select a word html table with a bookmark and want to count de number of rows.

Dim x = oDoc.Bookmarks(bkm).Range.Rows.Count

There are 3 rows in the table. The result is 1. Which I understand. But how to get the result of 3?

Thank you in advance.

Leo van den Berg

You need to tell the range method that you are counting rows in a Table.

Dim x = oDoc.Bookmarks(bkm).Range.Tables(1).Range.Rows.Count

All built-in collections are 0 based, so to access a particular index you need to subtract 1 from the natural index (eg 1=0, 2=1, 3=2). So when you're comparing rows.count, the maximum index will then be rows(rows.count-1)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM