Friday
Oct242008
Another blog for Visio Developers
Friday, October 24, 2008 at 12:09PM I just found a new resource for developing with Visio : Chris Hopkins' Visilog ( http://blogs.msdn.com/chhopkin/ )
Friday, October 24, 2008 at 12:09PM I just found a new resource for developing with Visio : Chris Hopkins' Visilog ( http://blogs.msdn.com/chhopkin/ )
Monday, October 20, 2008 at 2:30PM
Periodically I get a “how do I get started?” question about using automation Visio. So, in the interests of sharing, I’ll show 3 simple “Hello World” examples that you can build on for more complex tasks.
All these samples do the same thing: launch Visio 2007, create a new doc, and draw a rectangle with the text “Hello World”. Below is a sample of the output.
using System;using System.Collections.Generic;using System.Linq;using System.Text;// First Add a reference to the Visio Primary Interop Assembly:// In the "Solution Explorer", right click on "References", select "Add Reference"// The "Add Reference" dialog will launch// then in the ".NET" Tab select "Microsoft.Office.Interop.Visio"// Click "OK"using IVisio = Microsoft.Office.Interop.Visio;namespace Visio2007AutomationHelloWorldCSharp{class Program{static void Main(string[] args){IVisio.ApplicationClass visapp = new IVisio.ApplicationClass();IVisio.Document doc = visapp.Documents.Add("");IVisio.Page page = visapp.ActivePage;IVisio.Shape shape = page.DrawRectangle(1, 1, 5, 4);shape.Text = "Hello World";}}}
#light// Step 1 - Add a reference to the Visio Primary Interop Assembly// In the "Solution Explorer", right click on "References", select "Add Reference"// The "Add Reference" dialog will launch// then in the ".NET" Tab select "Microsoft.Office.Interop.Visio"// Click "OK"let visapp = new Microsoft.Office.Interop.Visio.ApplicationClass()let doc = visapp.Documents.Add("")let page = visapp.ActivePage;let shape = page.DrawRectangle(1.0, 1.0, 5.0, 4.0)shape.Text <- "Hello World";
import sysimport clrimport Systemclr.AddReference("Microsoft.Office.Interop.Visio")import Microsoft.Office.Interop.VisioIVisio = Microsoft.Office.Interop.Visiovisapp = IVisio.ApplicationClass()doc = visapp.Documents.Add("")page = visapp.ActivePageshape = page.DrawRectangle(1, 1, 5, 4)shape.Text = "Hello World"