共用方式為


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
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 命名空間