Microsoft Office Tutorials and References
In Depth Information
Set the document theme
Set the document theme
The objects available in the VSTO object model can be used to change the theme of
the Visio document. ThemeColors is the object used to manage the themes for Visio
documents. Under the ActivePage object, the ThemeColors and ThemeEffects
property is exposed when accessed through the Application object. The colors
available in the Visio.VisThemeColors object are assigned to the ThemeColors .
Similarly, the themes available for the Visio.VisThemeEffects object are assigned
to the ThemeEffects .
Let's see an example of how to change the default theme for shapes inside the
document, and give new color themes, programmatically, by using VSTO and C#.
Open Visual Studio 2008 to create a new Visio solution, as described earlier. In the
ThisAddIn.cs file, write the following program to set the theme for a Visio document:
private void ThisAddIn_S tartup(object sender, System.EventArgs e)
{
// Instance for Document object and calling the Add method on
the Document collection
Visio.Document PacktVisioDocument = this.Application.
Documents.Add("");
// Instance of Shape object
// Page Object has a PageSheet to set other page properties
Visio.Shape PacktShape = PacktVisioDocument.Pages[1].PageSheet;
// Set the page width property
PacktShape.get_Cells("PageWidth").Formula = "6 in";
// Set the page height property
PacktShape.get_Cells("PageHeight").Formula = "3 in";
// Code to add Shape to the document
// Access the Shapes file through Document object
Visio.Document PacktDocStencil = Application.Documents.
OpenEx("BASIC_M.VSS", (short)Visio.VisOpenSaveArgs.
visOpenDocked);
// Drop the new Square Shape to our Visio document
Visio.Shape PacktShape1 = PacktShape.
Drop(PacktDocStencil.Masters["Circle"], 2, 2);
// Adding text to inside the Shape
PacktShape1.Text = "Packt Shape One";
// Drop the new Triangle Shape to our Visio document
Visio.Shape PacktShape2 = PacktShape.
Drop(PacktDocStencil.Masters["Triangle"], 3, 3);
// Adding text to inside the Shape
 
Search JabSto ::




Custom Search