1

I am racking the net to find a way to programatically export/convert Microsoft Visio files to SVG using python.

I have a number of MS-Visio files (mostly created in Visio 2016), that I would like to export programatically, some have macros i.e .VSDM files, others may not i.e VSDX files.

Ideally I would like to run a script that iterates over the files and converts/exports them to visio without any user interaction, so far I've tried to use Win32com.client.Dispatch, but I am struggling to enable macros (for vsdm files) and gracefully close the file once the export/conversion is complete

Any ideas? Is there a good python 2.7 library?

Regards

  • Is there any reason why using VBA is not a better option? Or even VB.Net if you have Visual Studio (using Visio Interops) and can run executables on your network. The algorithm is simple - in a loop open file, save as SVG, close file, move on to next file. No fancy Win32com stuff required. – AJD Nov 17 '18 at 21:05
  • unfortunately VBA, and .NET are not options as the rest of the application that aims to use the exported/converted Visio files is already in Python – Man Wa kileleshwa Nov 17 '18 at 21:19
  • OK, I don't know Python. – AJD Nov 18 '18 at 05:30
  • I’m only familiar with vba but am assuming interop works more or less the same. The OpenEx method should let you open a document with macros disabled, so you don’t need to enable them. That’s assuming you don’t need them enabled. Otherwise you’d have to trust all macros. – Jon Fournier Nov 19 '18 at 01:01
  • And for closing files reliably I’ve found the only way is to kill Visio from the shell. – Jon Fournier Nov 19 '18 at 01:02
  • 1
    I do use win32com to automate Visio. Have a look at these 2 posts : http://visguy.com/vgforum/index.php?topic=8584.msg37382#msg37382 and http://visguy.com/vgforum/index.php?topic=8530.0 . The jupyter notebook I uploaded there should provide you a big amount of the functions you'll need for your project. Cheers, Y – y4cine Nov 19 '18 at 10:05
  • @y4cine could you post the link to the actual jupyter notebook? I can see the posts and the discussion, it looks very interesting. But I cannot see any of the code mentioned. – Man Wa kileleshwa Nov 21 '18 at 19:54
  • You need to log in in order to be able to download files from the forum. (Look forward to meet you there ;) ). – y4cine Nov 22 '18 at 10:00
  • What are exactly the problems with macros and closing files you face? You could have asked just that probably, since you seem to have the basics done already. – Nikolay Apr 09 '22 at 18:44
  • Have you seen ? [enter link description here](https://stackoverflow.com/questions/60638232/python-and-visio-365-automated-saving-to-svg) – Sedat YILMAZ Apr 15 '22 at 11:24

0 Answers0