WorkbookBase.Excel4MacroSheets 属性

获取一个 Microsoft.Office.Interop.Excel.Sheets 集合,该集合表示工作簿中的所有 Microsoft Office Excel 4.0 宏表。

命名空间:  Microsoft.Office.Tools.Excel
程序集:  Microsoft.Office.Tools.Excel.v4.0.Utilities(在 Microsoft.Office.Tools.Excel.v4.0.Utilities.dll 中)

语法

声明
Public ReadOnly Property Excel4MacroSheets As Sheets
    Get
public Sheets Excel4MacroSheets { get; }

属性值

类型:Microsoft.Office.Interop.Excel.Sheets
Microsoft.Office.Interop.Excel.Sheets 集合,表示工作簿中的所有 Microsoft Office Excel 4.0 宏表。

备注

下面的代码示例循环访问由 Excel4MacroSheets 属性返回的每个 Microsoft.Office.Interop.Excel.Worksheet,并将每个工作表的代码名称写入调试输出。

此示例针对的是文档级自定义项。

Private Sub DisplayExcel4MacroSheets()
    Dim sheetsCollection As Excel.Sheets = Me.Excel4MacroSheets
    Dim i As Integer
    For i = 1 To sheetsCollection.Count
        Dim sheet As Excel.Worksheet = _
            CType(sheetsCollection(i), Excel.Worksheet)
        System.Diagnostics.Debug.WriteLine(sheet.CodeName)
    Next i
End Sub
private void DisplayExcel4MacroSheets()
{
    Excel.Sheets sheetsCollection = this.Excel4MacroSheets;
    for (int i = 1; i < sheetsCollection.Count; i++)
    {
        Excel.Worksheet sheet = (Excel.Worksheet)sheetsCollection[i];
        System.Diagnostics.Debug.WriteLine(sheet.CodeName);
    }
}

.NET Framework 安全性

请参见

参考

WorkbookBase 类

Microsoft.Office.Tools.Excel 命名空间