Share via


DocumentBase.ContentControls 속성

문서에 있는 모든 콘텐트 컨트롤의 컬렉션을 가져옵니다.

네임스페이스:  Microsoft.Office.Tools.Word
어셈블리:  Microsoft.Office.Tools.Word.v4.0.Utilities(Microsoft.Office.Tools.Word.v4.0.Utilities.dll)

구문

‘선언
Public ReadOnly Property ContentControls As ContentControls
    Get
public ContentControls ContentControls { get; }

속성 값

형식: Microsoft.Office.Interop.Word.ContentControls
문서의 모든 콘텐츠 컨트롤이 들어 있는 ContentControls 컬렉션입니다.

설명

이 속성은 문서에 있는 네이티브 콘텐츠 컨트롤(즉, 문서에 있는 Microsoft.Office.Interop.Word.ContentControl 개체)의 컬렉션을 반환합니다.

문서에 있는 확장된 콘텐츠 컨트롤에 액세스하려면 Controls 속성을 사용합니다.

확장된 콘텐츠 컨트롤에 대한 자세한 내용은 콘텐츠 컨트롤을 참조하십시오.

예제

다음 코드 예제에서는 첫 번째 단락에 일반 텍스트 컨트롤을 추가하고 컨트롤 제목을 설정합니다. 그런 다음 문서 내의 모든 콘텐츠 컨트롤을 반복하고 각 콘텐츠 컨트롤의 형식 및 제목을 보여 주는 메시지 상자를 표시합니다. 이 예제를 사용하려면 문서 수준 프로젝트 ThisDocument 클래스에서 실행하십시오.

Private Sub IterateContentControls()
    Dim textControl1 As Word.ContentControl = _
        Me.ContentControls.Add( _
            Word.WdContentControlType.wdContentControlText, _
            Me.Paragraphs(1).Range)
    textControl1.Title = "First Name"

    For Each cc As Word.ContentControl In Me.ContentControls
        MessageBox.Show("Content control type: " + cc.Type.ToString() _
                        + ", title: " + cc.Title)
    Next
End Sub
private void IterateContentControls()
{
    object _range = this.Paragraphs[1].Range;
    Word.ContentControl textControl1 = this.ContentControls.Add(
            Word.WdContentControlType.wdContentControlText,
            ref _range);
    textControl1.Title = "First Name";

    foreach (Word.ContentControl cc in this.ContentControls)
    {
        MessageBox.Show("Content control  type: " 
            + cc.Type.ToString() + ", title: " + cc.Title);
    }
}

.NET Framework 보안

  • 직접 실행 호출자의 경우 완전히 신뢰합니다. 이 멤버는 부분적으로 신뢰할 수 있는 코드에서 사용할 수 없습니다. 자세한 내용은 부분 신뢰 코드에서 라이브러리 사용을 참조하십시오.

참고 항목

참조

DocumentBase 클래스

Microsoft.Office.Tools.Word 네임스페이스

기타 리소스

콘텐츠 컨트롤