pyatt
pyatt

Reputation: 57

How to create a new Visio file using pywin32?

I'm new to pywin32 and I'm trying to use it to create a blank Visio file. I know how to do this for an Excel spreadsheet, but I'm unsure of how to similarly create a new .vsdx file.

I know for making a new Excel sheet the code looks something like this:

import win32com.client
excel = win32com.client.Dispatch("Excel.Application")
workbook = excel.Workbooks.Add()
workbook.SaveAs(new_file_path+'\UpdatedSheet.xls')

How would I edit this so it creates a new Visio document instead?

Upvotes: 0

Views: 1098

Answers (1)

Hippolyte BRINGER
Hippolyte BRINGER

Reputation: 863

Try to use this :

visio = win32com.client.Dispatch("Visio.Application")
doc = visio.Documents.Add("Basic Diagram.vst")
doc.SaveAs(new_file_path+'/test.vsdx')

Upvotes: 2

Related Questions