Saturday
Jul142007
Simple F# interop with Visio example
Saturday, July 14, 2007 at 7:46PM A example that launches visio, creates a document, and then draws a rectangle. Nothing surprising, but useful as a starting point for automation.
Source Code
#r @"C:\Windows\assembly\gac\microsoft.office.interop.visio\12.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.Visio.dll";; let visio_app = new Microsoft.Office.Interop.Visio.ApplicationClass() ;; let doc = visio_app.Documents.Add( "" );; let page = doc.Pages.Item(1);; let shape = page.DrawRectangle( 1.0, 1.0, 5.0, 4.0);; do shape.Text <- "Hello World";;
Output
Notes
- Nice to get Intellisense with F# when running in Visual Studio 2005
- Next step is to use my "AutoVisio" assembly to make some nice drawings
Reader Comments