WorkbookBase.Theme 属性

获取应用于工作簿的主题。

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

语法

声明
Public ReadOnly Property Theme As OfficeTheme
    Get
public OfficeTheme Theme { get; }

属性值

类型:Microsoft.Office.Core.OfficeTheme
一个 Microsoft.Office.Core.OfficeTheme,表示应用于工作簿的主题。

示例

下面的代码示例将检索当前工作簿的主题。 然后,该示例显示在工作簿主题的字体方案中找到的主要字体和次要字体的名称。

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

Private Sub GetDocumentTheme()
    Dim theme As Office.OfficeTheme = Me.Theme
    Dim fontScheme As Office.ThemeFontScheme = theme.ThemeFontScheme
    Dim majorFont As Office.ThemeFont = fontScheme.MajorFont.Item( _
        Microsoft.Office.Core.MsoFontLanguageIndex.msoThemeLatin)
    Dim minorFont As Office.ThemeFont = fontScheme.MinorFont.Item( _
        Microsoft.Office.Core.MsoFontLanguageIndex.msoThemeLatin)
    MessageBox.Show("Name of major font in current document theme: " _
                    + majorFont.Name)
    MessageBox.Show("Name of minor font in current document theme: " _
                    + minorFont.Name)
End Sub
private void GetDocumentTheme()
{
    Office.OfficeTheme theme = this.Theme;
    Office.ThemeFontScheme fontScheme = theme.ThemeFontScheme;
    Office.ThemeFont majorFont = fontScheme.MajorFont.Item(
        Microsoft.Office.Core.MsoFontLanguageIndex.msoThemeLatin);
    Office.ThemeFont minorFont = fontScheme.MinorFont.Item(
        Microsoft.Office.Core.MsoFontLanguageIndex.msoThemeLatin);
    MessageBox.Show("Name of major font in current document theme: "
                    + majorFont.Name);
    MessageBox.Show("Name of minor font in current document theme: "
                    + minorFont.Name);
}

.NET Framework 安全性

请参见

参考

WorkbookBase 类

Microsoft.Office.Tools.Excel 命名空间