2017-09-21 3 views
1

여러 행이있는 Wordtable에는 각 행에 몇 개의 하위 테이블이 있는지 계산해야합니다. 각 행에는 두 개의 열이 있고 하위 테이블은 두 번째 열, 즉 Cell(row, 2)에 배치됩니다. 같은테이블 셀의 하위 테이블 수를 계산하십시오.

뭔가 :

For Each oRow In tblTable.Rows 
    iCountTables = tblTable.Cell(oRow, 2).Tables.Count 
Next 

하지만 실제로 작동합니다.

답변

0
Option Explicit 

Sub TableChildCounter() 

    Dim CurrentDoc As Document 
    Dim CurrentTbl As Table 
    Dim CurrentRow As Row 
    Dim TablesInCol2 As Long 

    Set CurrentDoc = ActiveDocument 



    For Each CurrentTbl In CurrentDoc.Tables 

     For Each CurrentRow In CurrentTbl.Rows 

      TablesInCol2 = CurrentRow.Cells(2).Tables.Count 
      MsgBox TablesInCol2 

     Next CurrentRow 

    Next CurrentTbl 

End Sub 
+0

그 일을했습니다! 많은 감사합니다! – RogZen

+0

@RogZen 좋은 물건. 모든 게시물에 도움이되는 답변과 올바른 답변을 upvote하는 것을 잊지 마십시오. stackoverflow를 즐기십시오. –