다음을 통해 공유


ControlCollection.AddBuildingBlockGalleryContentControl 메서드 (Range, String)

BuildingBlockGalleryContentControl 컨트롤을 문서의 지정된 범위에 추가합니다.

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

구문

‘선언
Function AddBuildingBlockGalleryContentControl ( _
    range As Range, _
    name As String _
) As BuildingBlockGalleryContentControl
BuildingBlockGalleryContentControl AddBuildingBlockGalleryContentControl(
    Range range,
    string name
)

매개 변수

반환 값

형식: Microsoft.Office.Tools.Word.BuildingBlockGalleryContentControl
문서에 추가된 BuildingBlockGalleryContentControl입니다.

예외

예외 상황
ArgumentNullException

name이 nullNull 참조(Visual Basic의 경우 Nothing)이거나 길이가 0인 경우

ControlNameAlreadyExistsException

이름이 같은 컨트롤이 ControlCollection에 이미 있는 경우

설명

이 메서드를 사용하여 런타임에 문서의 지정된 범위에 새 BuildingBlockGalleryContentControl을 추가합니다. 자세한 내용은 런타임에 Office 문서에 컨트롤 추가을 참조하십시오.

예제

다음 코드 예제에서는 문서의 시작 부분에 새 BuildingBlockGalleryContentControl을 추가합니다. BuildingBlockGalleryContentControl은 Microsoft Office Word에서 제공하는 식 문서 블록을 표시합니다.

이 버전은 문서 수준 사용자 지정을 위한 것입니다. 이 코드를 사용하려면 프로젝트의 ThisDocument 클래스에 해당 코드를 붙여넣고 ThisDocument_Startup 메서드에서 AddBuildingBlockControlAtRange 메서드를 호출합니다.

Dim buildingBlockGalleryControl2 As Microsoft.Office.Tools.Word.BuildingBlockGalleryContentControl

Private Sub AddBuildingBlockGalleryControlAtRange()
    Me.Paragraphs(1).Range.InsertParagraphBefore()
    buildingBlockGalleryControl2 = Me.Controls.AddBuildingBlockGalleryContentControl( _
        Me.Paragraphs(1).Range, "buildingBlockGalleryControl2")
    With buildingBlockGalleryControl2
        .PlaceholderText = "Choose an equation"
        .BuildingBlockCategory = "Built-In"
        .BuildingBlockType = Word.WdBuildingBlockTypes.wdTypeEquations
    End With
End Sub
private Microsoft.Office.Tools.Word.BuildingBlockGalleryContentControl buildingBlockControl2;

private void AddBuildingBlockControlAtRange()
{
    this.Paragraphs[1].Range.InsertParagraphBefore();

    buildingBlockControl2 = this.Controls.AddBuildingBlockGalleryContentControl(
       this.Paragraphs[1].Range, "buildingBlockControl2");
    buildingBlockControl2.PlaceholderText = "Choose an equation";
    buildingBlockControl2.BuildingBlockCategory = "Built-In";
    buildingBlockControl2.BuildingBlockType = Word.WdBuildingBlockTypes.wdTypeEquations;
}

이 버전은 .NET Framework 4를 대상으로 하는 응용 프로그램 수준 추가 기능을 위한 것입니다. 이 코드를 사용하려면 프로젝트의 ThisAddIn 클래스에 해당 코드를 붙여넣고 ThisAddIn_Startup 메서드에서 AddBuildingBlockControlAtRange 메서드를 호출합니다.

Dim buildingBlockGalleryControl2 As BuildingBlockGalleryContentControl

Private Sub AddBuildingBlockGalleryControlAtRange()
    If Me.Application.ActiveDocument Is Nothing Then
        Return
    End If

    Dim vstoDoc As Document = Globals.Factory.GetVstoObject(Me.Application.ActiveDocument)
    vstoDoc.Paragraphs(1).Range.InsertParagraphBefore()
    buildingBlockGalleryControl2 = vstoDoc.Controls.AddBuildingBlockGalleryContentControl( _
        vstoDoc.Paragraphs(1).Range, "buildingBlockGalleryControl2")
    With buildingBlockGalleryControl2
        .PlaceholderText = "Choose an equation"
        .BuildingBlockCategory = "Built-In"
        .BuildingBlockType = Word.WdBuildingBlockTypes.wdTypeEquations
    End With
End Sub
private Microsoft.Office.Tools.Word.BuildingBlockGalleryContentControl buildingBlockControl2;

private void AddBuildingBlockControlAtRange()
{
    if (this.Application.ActiveDocument == null)
        return;

    Document vstoDoc = Globals.Factory.GetVstoObject(this.Application.ActiveDocument);
    vstoDoc.Paragraphs[1].Range.InsertParagraphBefore();

    buildingBlockControl2 = vstoDoc.Controls.AddBuildingBlockGalleryContentControl(
       vstoDoc.Paragraphs[1].Range, "buildingBlockControl2");
    buildingBlockControl2.PlaceholderText = "Choose an equation";
    buildingBlockControl2.BuildingBlockCategory = "Built-In";
    buildingBlockControl2.BuildingBlockType = Word.WdBuildingBlockTypes.wdTypeEquations;
}

.NET Framework 보안

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

참고 항목

참조

ControlCollection 인터페이스

AddBuildingBlockGalleryContentControl 오버로드

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

기타 리소스

런타임에 Office 문서에 컨트롤 추가

호스트 컨트롤의 도우미 메서드

방법: Word 문서에 콘텐츠 컨트롤 추가