2017-01-23 1 views
0

다음 표가 있습니다.반복 섹션 내용 컨트롤 안에 중첩 된 개별 콘트롤 주소 지정

word

각 셀은 개별적 평문 컨텍스트 제어를 나타낸다. 전체 행은 "ENTRY"라는 태그가 붙은 반복 섹션 컨텍스트 제어 ("RSCC")로 래핑됩니다. 아시다시피,이 같은 행을 추가 할 수 있습니다

Sub MACRO1() 
' 
' MACRO1 Macro 
' 

Dim anchor_cc As ContentControl 

Set anchor_cc = ActiveDocument.SelectContentControlsByTag("ENTRY").Item(1) 

' Add one more row 
total = 1 
For counter = 1 To total 
    With anchor_cc 
     .AllowInsertDeleteSection = True 
     .RepeatingSectionItems(1).InsertItemAfter 
    End With 
Next counter 

End Sub 

나는 또한이 같은 INDIVIDUAL RSCC를 해결할 수있는 출력합니다 대화 상자에서 전체 행의 텍스트 내용 :

Sub MACRO2() 
Dim anchor_cc As ContentControl 

Set anchor_cc = ActiveDocument.SelectContentControlsByTag("ENTRY").Item(1) 

With anchor_cc 
    For counter = 1 To .RepeatingSectionItems.Count 
     MsgBox (.RepeatingSectionItems(counter).Range) 
    Next counter 
End With 

End Sub 

해당 RSCC의 개별 셀을 어떻게 처리합니까? 예를 들어 첫 번째 행의 첫 번째 셀을 처리하려고한다고 가정 해 봅시다. 첫 번째 행을 처리하기는 쉽습니다. 난 그냥 즉 1-.RepeatingSectionItems 지수, 내가 그 행의 첫 번째 셀에 액세스하려면 어떻게

.RepeatingSectionItems(1)

을 설정할 수 있습니까? 또는 번째로 세포입니까? 셀은 개별 텍스트 텍스트 컨텍스트 컨트롤임을 기억하십시오. 그 대답이 전혀 바뀌는 지 모르겠습니다.

답변

0

나는 Word 2013 또는 2016에 포함되어 있다고 믿는 .RepeatingSectionItems 속성을 사용할 수 없습니다.이 순간은 MS Word 2010의 선두입니다.

Dim ccEntry As ContentControl 
Set ccEntry = ActiveDocument.SelectContentControlsByTitle("ENTRY")(1) 

'to get row... 
Dim tblRow As Row 
Set tblRow = ccEntry.Range.Tables(1).Rows(ccEntry.Range.Information(wdEndOfRangeRowNumber)) 

'get first cell 
Dim tblCell As Cell 
Set tblCell = tblRow.Cells(1) 
    Debug.Print tblCell.Range.Text 
:

아주 간단하게이 행에 필요한 셀을 참조 다음 (당신이 당신의 techinque를 사용할 수있는 경우) 첫 번째 행을 참조하는이 논리를 시도하고