Share via


DocumentBase.ApplyTheme Method

Applies a theme to a document, if the document is open.

Namespace:  Microsoft.Office.Tools.Word
Assembly:  Microsoft.Office.Tools.Word.v4.0.Utilities (in Microsoft.Office.Tools.Word.v4.0.Utilities.dll)

Syntax

'Declaration
Public Sub ApplyTheme ( _
    name As String _
)
public void ApplyTheme(
    string name
)

Parameters

  • name
    Type: System.String

    The name of the theme plus any theme formatting options you want to apply.

Remarks

The format of the name string is "theme nnn" where theme and nnn are defined as follows:

theme – The name of the folder that contains the data for the requested theme. (The default location for theme data folders is C:\Program Files\Common Files\Microsoft Shared\Themes11.) You must use the folder name for the theme rather than the display name that appears in the Theme dialog box.

nnn – A three-digit string that indicates which theme formatting options to activate (1 to activate, 0 to deactivate). The digits correspond to the VividColors, ActiveGraphics, and BackgroundImage check boxes in the Theme dialog box. If this string is omitted, the default value for nnn is "011" (Active Graphics and Background Image are activated).

Examples

The following code example uses the ApplyTheme method to apply the "Afternoon 011" theme to the current document. To use this example, run it from the ThisDocument class in a document-level project.

Private Sub DocumentApplyTheme()
    Me.ApplyTheme("AFTRNOON 011")
End Sub
private void DocumentApplyTheme()
{
    this.ApplyTheme("AFTRNOON 011");
}

.NET Framework Security

See Also

Reference

DocumentBase Class

Microsoft.Office.Tools.Word Namespace