Updating Visio SharePoint Hyperlinks in Code

In last month’s entry, I showed how you can connect Visio timelines to SharePoint calendars, but I was unable to provide VBA code for automatically update the hyperlinks because my laptop had some issues.  Well, a month later, after a holiday and a back injury, I have provided some VBA code below that enables the hyperlinks to become usable with the SharePoint calendar used in the example.
Public Sub AmendLinks()
    Const urlCell As String = “_VisDM_Encoded_Absolute_URL”
    Const idProp As String = “Prop._VisDM_ID”
    Dim shp As Visio.Shape
Dim pag As Visio.Page
    Dim i As Integer
urlOld As String
id As String
    Dim urlNew As String
    For Each pag In Visio.ActiveDocument.Pages
         For Each shp In pag.Shapes
             If shp.CellExistsU(“Prop.” & urlCell, Visio.visExistsAnywhere) _
                 And shp.CellExistsU(idProp, Visio.visExistsAnywhere) Then
                 urlOld = shp.Cells(“Prop.” & urlCell).ResultStr(“”)
id = shp.Cells(idProp).ResultStr(“”)
urlNew = Left(urlOld, Len(urlOld) – 5 – Len(Format(id, “#”))) & “DispForm.aspx?ID=” & Format(id, “#”)
shp.Cells(“Hyperlink.” & urlCell & “.Address”).FormulaU = “=””” & urlNew & “”””
             End If
         Next shp
     Next pag
End Sub

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.


O365 and SharePoint

Simplify Tasks

Want to learn the simple way?

Paul Turley's SQL Server BI Blog

sharing my experiences with the Microsoft data platform, SQL Server BI, Data Modeling, SSAS Design, Power Pivot, Power BI, SSRS Advanced Design, Power BI, Dashboards & Visualization since 2009

John Goldsmith's visLog

be smart, be clear, be visual ...

Mo's blog

Personal views on Dynamics 365 for Operations and Technical Architecture.

Chris Webb's BI Blog

Microsoft Power BI, Analysis Services, MDX, DAX, M, Power Pivot and Power Query


Azure Solutions for Office 365, and more...

Rob Fahrni



Life with Visio and other Microsoft Toys!

Nilsandrey's Weblog

Just another WordPress.com weblog

Things that Should be Easy

Every so often (too often in the IT industry) I encounter things that should have been very easy to do but turned out to be far too complicated. My favorite topics include SharePoint, .Net development, and software architecture, especially distributed systems.

Visio Guy

Smart graphics for visual people

%d bloggers like this: