在word vba中表格用Table对象表示。
如果要获取一个word文档中的表格数量,可以使用如下的vba代码:
Sub exceloffice() '作者QQ:1722187970,微信:xycgenius,微信公众号exceloffice Dim oDoc As Document Set oDoc = Word.ActiveDocument Dim oT As Table With oDoc MsgBox .Tables.Count End With End Sub
如果要遍历每一个word表格,集合的下标是从1开始的,如下代码所示:
Sub exceloffice() '作者QQ:1722187970,微信:xycgenius,微信公众号exceloffice Dim oDoc As Document Set oDoc = Word.ActiveDocument Dim oT As Table With oDoc iCount = .Tables.Count For i = 1 To iCount Set oT = .Tables(i) Next i End With End Sub
发表评论