Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I am new to Perl and am looking to use Perl to control Microsoft Visio. I am able to start visio from Perl. But I can't seem to figure out how to draw in it. Anyone ever do this? Thanks.

Replies are listed 'Best First'.
Re: Access Visio in Perl
by chunlou (Curate) on Jul 22, 2003 at 19:24 UTC

    If your drawing is not completely free flowing but could be modelled as data-driven type, you could use Visio Database Wizard feature instead. It's a lot easier to manipulate data than to draw programmatically.

    You could try to draw a few sample drawings from Visio. Use Database Wizard to store the drawings into an ODBC-compliant DB, manipulate the data and have Visio draw from the data.

      I have a data dictioary and an io table (what data elements/variables each subprogram is sending and where they are sending them to) defined in MS Access. My plan is to have Perl access this data and generate Data Flow Diagrams. I have successfully accessed the database and am able to place standard objects (a circle, representing a process) from Visio's stencel onto the Visio document. What I can't do is name that circle (ie. I want the circle to be called "Process X". I looked at using Visio's 'database wizard'. The best I could make of their 'on-line' help is that I could draw the data flow and link the data to MS Access. The diagram would could never change, but the data would stay updated. Any ideas on how to name a bubble in Visio via Perl?
        Suppose you have a shape in test.vsd:
        use strict; use warnings; use Win32::OLE; $Win32::OLE::Warn = 3; my $path = "D:\\FilePath\\"; my $file = "test.vsd"; my $Visio = Win32::OLE->new('Visio.Application', 'Quit'); my $VDocs = $Visio->Documents; my $VDoc = $VDocs->Open("$path$file"); my $VPage = $VDoc->Pages->Item(1); my $VShapes = $VPage->Shapes; my $VShape = $VShapes->Item(1); $VShape->{Text} = "Biggie Ole"; print $VShape->{Text}; $VDoc->SaveAs($path."test2.vsd");
        Open Up the Shrinkwrap with OLE is a good (albeit old) article on Visio OLE (a 2MB PDF).