Share via


WorkbookBase.CommandBars 속성

Microsoft Office Excel 명령 모음을 나타내는 Microsoft.Office.Core.CommandBars 개체를 가져옵니다.

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

구문

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

속성 값

형식: Microsoft.Office.Core.CommandBars
Microsoft Office Excel 명령 모음을 나타내는 Microsoft.Office.Core.CommandBars 개체입니다.

설명

통합 문서가 다른 응용 프로그램에 포함되어 있고 사용자가 해당 통합 문서를 두 번 클릭할 때 활성화되는 경우, 이 속성과 Workbook 개체를 함께 사용하면 다른 응용 프로그램에서도 사용할 수 있는 Excel 명령 모음의 집합이 반환됩니다. 그 밖의 경우 이 속성과 Workbook 개체를 함께 사용하면 nullNull 참조(Visual Basic의 경우 Nothing)이 반환됩니다. 통합 문서에 연결된 명령 모음의 집합을 프로그래밍 방식으로 반환하는 방법은 없습니다. 명령 모음은 통합 문서가 아니라 응용 프로그램과 연결되기 때문입니다. 해당 응용 프로그램이 Excel이 아닌 경우에는 Excel 응용 프로그램 명령 모음에 액세스할 수 있도록 이 속성이 통합 문서에 존재합니다.

예제

다음 코드 예제에서는 CommandBars 속성을 사용하여 표시되지 않은 사용자 지정 명령 모음을 모두 삭제합니다. 이 예제에서는 현재 통합 문서가 다른 응용 프로그램에 포함되어 있다고 가정합니다.

이 예제는 문서 수준 사용자 지정을 위한 것입니다.

Private Sub WorkbookCommandBars()
    If Not (Me.CommandBars Is Nothing) Then
        Dim i As Integer
        For i = 1 To Me.CommandBars.Count
            If Not Me.CommandBars(i).BuiltIn AndAlso Not _
                Me.CommandBars(i).Visible Then
                Me.CommandBars(i).Delete()
            End If
        Next i
    Else
        MsgBox("This workbook must be opened in another " & _
            "application to use the CommandBars property.")
    End If
End Sub
private void WorkbookCommandBars()
{
    if (this.CommandBars != null)
    {
        for (int i = 1; i <= this.CommandBars.Count; i++)
        {
            if (!this.CommandBars[i].BuiltIn &&
                !this.CommandBars[i].Visible)
            {
                this.CommandBars[i].Delete();
            }
        }
    }
    else
    {
        MessageBox.Show("This workbook must be opened in another " +
            "application to use the CommandBars property.");
    }
}

.NET Framework 보안

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

참고 항목

참조

WorkbookBase 클래스

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