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

Hi, I want to access a visio file from perl and save it as png or jpg after processing it. I tried with Win32::OLE and saved it as png.The file got generated but it contains nothing.Invalid format. The code line I am using is: $document1->saveAs("visiofile.png");

Replies are listed 'Best First'.
Re: Accessing Visio in perl
by marto (Cardinal) on Apr 19, 2011 at 09:30 UTC

    If you're going to use Win32::OLE to try and automate things it's often helpful to use the macro recorder to show you what's going on. For example, the VBA code generated by the macro recorder when saving as a png file:

    Application.ActiveWindow.Page.Export "c:\test.png"

    I'll leave the conversion to perl as an exercise, How do I convert a VBA macro to Perl? should be helpful.

      Thanks a lot for your reply.. The working code is:
      $Visio->ActiveDocument->Pages(1)->Export($path."Drawing.jpg");
      ---- Thanks again for exposing me to a generalized solution.
Re: Accessing Visio in perl
by Corion (Patriarch) on Apr 19, 2011 at 09:18 UTC

    Just giving a file a .png extension does not make Visio export in PNG format. Have you investigated whether Microsoft Visio can save in PNG format?

      Yes...I have done it using C#..