Automating Microsoft Visio

This example opens a Microsoft Visio document and prints the save-time and creation-time of the Visio document:

import sys, win32com.client

doc = sys.argv[1]
try:
     visio = win32com.client.Dispatch("Visio.Application")
     visio.Visible = 0
     try:
          dwg = visio.Documents.Open(doc)
          print dwg.TimeCreated, ",", dwg.TimeSaved
     except Exception, e:
          print "Error", e
     dwg.Close()
     visio.Quit()
except Exception, e:
     print "Error opening file",e

Leave a Reply

Your email address will not be published. Required fields are marked *