title: How to add a link to a Visio document via Python
body: <p>I googled for some code to create Visio documents via Python. I want to add shapes, and have hyperlinks. So that you can click on the shape, or preferably on the text inside the shape, and get to a URL.</p>
  
  <pre><code>import os
  import win32com.client
  
  from win32com.client import constants
  
  appVisio = win32com.client.Dispatch("Visio.Application")
  appVisio.Visible =1
  
  doc = appVisio.Documents.Add("Basic Diagram.vst")
  pagObj = doc.Pages.Item(1)
  stnObj = appVisio.Documents("Basic Shapes.vss")
  mastObj = stnObj.Masters("Rectangle")
  
  shpObj1 = pagObj.Drop(mastObj, 4.25, 5.5)
  shpObj1.Text = "This is some text."
  
  shpObj2 = pagObj.Drop(mastObj, 2, 2)
  shpObj2.Text = """This is some more text. {\field{\*\fldinst HYPERLINK "http://www.google.com/"}{\fldrslt http://www.google.com}}"""
  
  
  connectorMaster = appVisio.Application.ConnectorToolDataObject
  
  connector = pagObj.Drop(connectorMaster, 0, 0)
  connector.Cells("BeginX").GlueTo(shpObj1.Cells("PinX"))
  connector.Cells("EndX").GlueTo(shpObj2.Cells("PinX"))
  
  doc.SaveAs(r'C:\utils\MyDrawing.vsd')
  doc.Close()
  
  appVisio.Visible =0
  appVisio.Quit()
  </code></pre>
  
  <p>The RTF link is ignored - I tried that. Visio can add hyperlinks in the UI. So... does anyone know how I can add a link via Python here?</p>