DocumentBase.CopyStylesFromTemplate Method
Copies styles from the specified template to a document.
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 CopyStylesFromTemplate ( _
template As String _
)
public void CopyStylesFromTemplate(
string template
)
Parameters
- template
Type: System.String
The template file name.
Remarks
When styles are copied from a template to a document, like-named styles in the document are redefined to match the style descriptions in the template. Unique styles from the template are copied to the document. Unique styles in the document remain intact.
Examples
The following code example uses the CopyStylesFromTemplate method to copy the styles from the specified template to the current document. This example assumes that a template file named Sales96.dot exists on the computer at C:\Program Files\Microsoft Office\Templates. To use this example, run it from the ThisDocument class in a document-level project.
Private Sub DocumentCopyStylesFromTemplate()
Me.CopyStylesFromTemplate("C:\Program Files\Microsoft Office\" + _
"Templates\Sales96.dot")
End Sub
private void DocumentCopyStylesFromTemplate()
{
string template =
"C:\\Program Files\\Microsoft Office\\Templates\\Sales96.dot";
this.CopyStylesFromTemplate(template);
}
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.