共用方式為


WorkbookBase.Theme 屬性

定義

取得套用至活頁簿的佈景主題。

public:
 property Microsoft::Office::Core::OfficeTheme ^ Theme { Microsoft::Office::Core::OfficeTheme ^ get(); };
public Microsoft.Office.Core.OfficeTheme Theme { get; }
member this.Theme : Microsoft.Office.Core.OfficeTheme
Public ReadOnly Property Theme As OfficeTheme

屬性值

Microsoft.Office.Core.OfficeTheme,代表套用至活頁簿的主題。

範例

下列程式代碼範例會擷取目前活頁簿的主題。 然後,此範例會顯示活頁簿主題字型配置中找到的主要字型和次要字型名稱。

此範例適用於檔層級自定義。

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);
}
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

適用於