NamedRange.Creator 属性

获取一个 32 位整数,该整数指示已在其中创建 NamedRange 控件的应用程序。

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

语法

声明
ReadOnly Property Creator As XlCreator
XlCreator Creator { get; }

属性值

类型:Microsoft.Office.Interop.Excel.XlCreator
XlCreator 值之一。

备注

如果 NamedRange 控件是在 Microsoft Office Excel 中创建的,则此属性返回十六进制数 5843454C,该数字与字符串“XCEL”等效。

示例

下面的代码示例先创建一个 NamedRange,然后使用 Creator 属性来确定 NamedRange 是否是在 Microsoft Office Excel 中创建的。

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

Private displayCreatorRange As Microsoft.Office.Tools.Excel.NamedRange

Private Sub DisplayCreator()
    displayCreatorRange = Me.Controls.AddNamedRange( _
        Me.Range("C3", "E5"), "displayCreatorRange")
    displayCreatorRange.Select()
    If Me.displayCreatorRange.Creator = _
        Excel.XlCreator.xlCreatorCode Then
        MessageBox.Show("This NamedRange control was " & _
            "created in Microsoft Office Excel.")
    Else
        MessageBox.Show("This NamedRange control was " & _
            "not created in Microsoft Office Excel.")
    End If
End Sub
Microsoft.Office.Tools.Excel.NamedRange displayCreatorRange;
private void DisplayCreator()
{
    displayCreatorRange = this.Controls.AddNamedRange(
        this.Range["C3", "E5"], "displayCreatorRange");
    displayCreatorRange.Select();
    if (this.displayCreatorRange.Creator == 
        Excel.XlCreator.xlCreatorCode)
    {
        MessageBox.Show("This NamedRange control was created in " +
            "Microsoft Office Excel.");
    }
    else
    {
        MessageBox.Show("This NamedRange control was not created in " +
            "Microsoft Office Excel.");
    }
}

.NET Framework 安全性

请参见

参考

NamedRange 接口

Microsoft.Office.Tools.Excel 命名空间