Microsoft Office Tutorials and References
In Depth Information
Dynamically creating a new Visio document
By using the object model, you will considerably reduce your development cycle. For
example, built-in classes offered by the object model expose methods that will solve
many of your requirements, and also save development time.
Dynamically creating a new Visio document
The main advantage of programming for any kind of application is automating
some of the manual operations. For any kind of document-based applications,
creating a new document will be the primary operation to be performed. To test
the ability of programming support for the application, we can create the new
document dynamically by using the programming language supported for
customizing the application.
Let's create a sample exercise for creating a Visio document dynamically by using
VSTO and C# programming.
Open Visual Studio 2008 to create a new Visio solution, as described earlier. Write the
following program to create a Visio document dynamically in the ThisAddIn.cs file:
private void ThisAddIn_Startup(object sender, System.EventArgs e)
// Instance for Document object and calling the Add method on the
Document collection
Visio.Document PacktVisioDocument = this.Application.Documents.
// 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 = "13.5 in";
// Set the page height property
PacktShape.get_Cells("PageHeight").Formula = "5.5 in";
Search JabSto ::

Custom Search