Automating Microsoft Project

This script shows how to automate Microsoft Project.

import win32com.client
doc = 'C:\\Project1.mpp'
try:
     mpp = win32com.client.Dispatch("MSProject.Application")
     mpp.Visible = 1
     try:
          mpp.FileOpen(doc)
          proj = mpp.ActiveProject
          print
proj.BuiltinDocumentProperties(11), ",",
proj.BuiltinDocumentProperties(12)
     except Exception, e:
          print "Error", e
     mpp.FileSave()
     mpp.Quit()
except Exception, e:
     print "Error opening file",e

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