« Advanced Gradients with Visio 2007 and Visual Studio 2008 | Main | Bar Chart Explorations with POV-Ray »
Saturday
Jul142007

Simple F# interop with Visio example

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

image

 

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

PrintView Printer Friendly Version

EmailEmail Article to Friend

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>