• Skip to main content
  • Skip to primary sidebar
  • Skip to footer

bVisual

  • Home
  • Services
    • How Visio smartness can help your business
    • Visio visual in Power BI
    • Visio Consulting Services
    • Visio Bureau Services
    • Visio Training and Support Services
  • Products
    • SS Plus
    • LayerManager
    • visViewer
    • Metro Icons
    • Rules Tools for Visio
    • The Visio 2010 Sessions App
    • Multi-Language Text for Visio
    • Document Imager for Visio
    • multiSelect for Visio
    • pdSelect for Visio
  • Case Studies
    • Case studies overview
    • Visualizing Construction Project Schedules
    • Visio Online Business Process Mapping
    • Nexans Visio Template
    • CNEE Projects, WorldCom
    • Chase Manhattan Bank
  • News
    • Recent news
    • News archive
  • Resources
    • Articles➡
      • ShapeSheet Functions A-Z
      • Comparing Visio for the Web and Desktop
      • Customising Visio Shapes for the Web App
      • Key differences between the Visio desktop and web apps
      • Using the Visio Data Visualizer in Excel
      • Using Visio in Teams
      • Creating Visio Tabs and Apps for Teams with SharePoint Framework (SPFx)
      • Designing Power Automate Flows with Microsoft Visio
      • Innovative uses of Visio Lists
    • Webcasts ➡
      • Visio in Organizations
      • My session and other Visio sessions at MSIgnite 2019
      • Power up your Visio diagrams
      • Vision up your Visio diagrams
      • The Visio 2010 MVP Sessions
    • Visio Web Learning Resources
    • Books➡
      • Mastering Data Visualization with Microsoft Visio
      • Microsoft Visio Business Process Diagramming and Validation
      • Visualizing Information with Microsoft Visio
  • Blog
    • Browse blog articles
    • Visio Power BI articles
    • Visio for Web articles
    • Visio blog on Orbus website
    • A history of messaging and encryption
  • About us
    • About bVisual
    • Testimonials
    • Bio of David Parker
    • Contact Us
    • Website Privacy Policy
    • Website terms and conditions
    • Ariba Network

bVisual Blog by David Parker

Published on January 4, 2009 by David Parker

Closing Shape Data Sets window in Visio 2007

A colleague recently asked me how to close the Shape Data Sets window so that it does not automatically re-open when you open the drawing again.  My first thoughts was that this is surely a simple matter of saving the workspace, but it appears that this is not the case!  I found that other Visio users have had the same problem, so I thought I would present my solution (until Microsoft fix it!).

image
[Read more…] about Closing Shape Data Sets window in Visio 2007

Filed Under: Visio

Published on December 15, 2008 by David Parker

Using the Microsoft Visio Viewer (and introducing visViewer)

Microsoft Outlook 2007 installs the Microsoft Visio Viewer (vviewer.dll via vpreview.exe) by default, so that native Visio files can be seen in all their glory (almost).  In this blog I’ll show that the Visio Viewer actually provides access to the Shape Data (Custom Properties), Hyperlinks, Reviewers Markup and Layers.  All this without even having Visio installed!

This is great because multiple page documents can be browsed, panned and zoomed.

However, this presentation of the Microsoft Office Visio previewer hides quite a lot of its functionality of this, so it is difficult to toggle layer and reviewers markup visibility, or to view the shape data/custom properties.

There is an existing web article which demonstrates how to use the Visio Viewer in SharePoint (http://www.wssdemo.com/Pages/visio.aspx), and the same method can be used in a web page.  This presentation of the Visio Viewer does enable the user to get the extra functionality, but it does not allow the shape data to be searched, listed or extracted.  Neither does it allow you to print easily.

Well, I wrote visViewer as a vb.net wrapper for the Microsoft Visio Viewer 2003 version several years ago, and now I have updated it for the Microsoft Visio Viewer 2007 (see  http://www.bvisual.net/Products/visViewer.aspx). The newer version provides access to shapes with shapes, just as the reporting tool full version of Visio was enhanced to provide access to shapes within shapes. This time I have released it as shareware, so feel free to try it, and, if you like it and use it commercially, you may wish to donate towards its development.

visViewer demonstrates that all the Shape Data on all of the shapes on each page in the Visio document are visible to code.  The main principle is that the CurrentPageIndex of the Viewer control needs to be set to an integer number up to the PageCount before the shapes can be read.  For example the following block of code shows how you can

With Me.AxViewer1
 .CurrentPageIndex = n
 For
 lShape As Integer
 = 1 To .ShapeCount
 ‘You can use .get_ShapeName(lShape)
     For
 lProperty As Integer
 = 1 To
 .get_CustomPropertyCount(lShape)
        ‘ You can use .get_CustomPropertyName(lShape, lProperty)

        ‘ and .get_CustomPropertyValue(lShape, lProperty)

    Next lProperty 
     For
 lHyperlink As Integer
 = 1 To
 .get_HyperlinkCount(lShape)
        ‘ You can use .get_HyperlinkAddress(lShape, lHyperlink)

    Next lProperty
 Next lShape  
 End With

Once you have read the data inside each shape, then you can provide searching and exporting.

In addition to reading the Shape Data, I also collect the Hyperlinks, and thus it is possible to show multiple hyperlinks on shapes, and to provide the ability to follow them.

One shortcoming of the Visio Viewer is the lack of any method to zoom to a shape in the document.  Strangely, there is a method to the shape at any xy co-ordinate (get_ShapeAtPoint), but not one to get the xy co-ordinate of a shape.

Another shortcoming of the Visio Viewer is the lack of printing, but I have been able to partially address this by using the PrintForm method from the Visual Basic Power Packs.  However, this only outputs raster, which is never going to be as crisp as vectors.

I decided to use the Microsoft ReportViewer (because it is simple and royalty free) for the reports that provide printing, or export to Excel or Pdf, of the shape data.

Lastly, I provided the ability to open a Visio document from the menu, or by dropping a Visio document on to the Visio Viewer panel, or by opening from Window Explorer (if the msi installation is used rather than the ClickOnce).

I hope that visViewer proves useful to non-Visio and Visio users alike, and hope that it encourages the use of Visio files as a portable data graphic file format.

Filed Under: Visio, Visio Viewer, visViewer

Published on November 3, 2008 by David Parker

Tech-Ed EMEA 2008 IT Professionals Conference

I am on the Office Client Ask the Experts booth on Wednesday, Thursday, Friday this week in sunny Barcelona.  I am hoping that there will be some enlightened IT Pros who can see the value of using Visio to analyse, plan and deploy various network and systems. I have been an an ATE booth at Tech-Ed twice before, but that was at the developers side of the conference, rather than the IT pros, and I was disappointed with the lack of understanding of the power of Visio, so I am looking forward to presenting the built-in capabilities of Visio Professional and the number of IT Pro related add-ins that have become available.

Filed Under: Visio

Published on October 17, 2008 by David Parker

Importing KML Files into Visio

In my last blog, I demonstrated how you can import a map image from Maps Live, and calibrate it in preparation for importing any KML files into it (http://bvisual.spaces.live.com/blog/cns!3350D61BC93733A9!752.entry).  In this blog, I will complete the import of KML files exported from Maps Live.

I created two base map images in Visio, side by side,so that I can demonstrate that the import can be done to any prepared image, anywhere in Visio. Of course, you could have the two images on top of each other, on different layers, so that you can switch between Road and Aerial view by just changing the visibility of their layers.

image

[Read more…] about Importing KML Files into Visio

Filed Under: Geographic, ShapeSheet Formulas, VBA, Visio

Published on September 30, 2008 by David Parker

Moving Between Visio and KML

I have become increasingly concerned about using data with maps of one sort or another.  The new release of SQL Server 2008 includes Spatial Data (http://www.microsoft.com/sqlserver/2008/en/us/spatial-data.aspx ) which provides the ability to map data as boundaries (polylines), multi-segment lines (linestrings) and points.  Virtual Earth has also just been revamped with the 6.2 release ( http://www.microsoft.com/virtualearth/ ).  There are some great articles on integrating the two together … but, as usual, I want to bring Visio into the mix too!  That will enable me to use Link Data to Shapes ( see http://bvisual.spaces.live.com/blog/cns!3350D61BC93733A9!330.entry ) or even create bubble-charts (see http://bvisual.spaces.live.com/blog/cns!3350D61BC93733A9!135.entry ).

Well, actually, we could use an existing XML format for spatial data to enable Visio to read from a variety of mapping tools.   Indeed, Microsoft have also started supporting KML (http://en.wikipedia.org/wiki/Kml), a format popularised by Google!  Maps Live , which is powered by Virtual Earth, (http://maps.live.com/ ) allows you to export and import KML files via the collections toolset.

image

Getting the Shapes Collection

You can use the tools in the collections editor to draw areas (polylines) , path (linestrings) and pushpins (points).

image

You can then use Actions / Export / KML to produce an XML file in KML format.  I have XMLNotepad 2007 (free from Microsoft http://msdn.microsoft.com/en-gb/xml/default.aspx) to view the KML file below:

image

Getting the Map Image

This is fine for the data, but what about the map image?  Well, rather than use a screen capture tool, I decided to use the Print link in Live Search Maps that opens up a new web browser window.

image

The map image is actually made up of image tiles, so you can then select each one then use the right mouse menu item Copy to paste them onto a Visio page.

image

Similarly, you could do the same for the Road view.

image

I have placed the tiles in their groups roughly on a Visio page …

image

The I used a bit of VBA code (called AbutTiles) to ensure that the image tiles are properly abutted.

image

Whilst we have control of the map image(s), we could group them together, then lock the group and aspect, and change the selection mode to group only.

image

Public Sub AbutTiles()
If Visio.ActiveWindow.Selection.Count = 0 Then
    Exit Sub
End If
Dim shp As Visio.Shape
Dim cols As Integer
Dim rows As Integer
Dim col As Integer
Dim row As Integer
Dim wdth As Double
Dim hght As Double
Dim top As Double
Dim left As Double
Dim tolerance As Double
Dim anchorShape As String

‘Assume that all shapes are same height and width
wdth = Visio.ActiveWindow.Selection.Item(1).Cells(“Width”).ResultIU
hght = Visio.ActiveWindow.Selection.Item(1).Cells(“Height”).ResultIU
tolerance = wdth * 0.3

‘Assume that the shapes were selected from top left to bottom right
For Each shp In Visio.ActiveWindow.Selection
    If cols = 0 Then
        cols = 1
        rows = 1
        col = 1
        row = 1
        left = shp.Cells(“PinX”).ResultIU
        top = shp.Cells(“PinY”).ResultIU
        anchorShape = shp.NameID
    Else
        If shp.Cells(“PinX”).ResultIU > (left + tolerance) Then
            col = col + 1
        Else
            col = 1
        End If
        If shp.Cells(“PinY”).ResultIU < (top – tolerance) And col = 1 Then
            row = row + 1
        End If
        If cols < col Then
            cols = col
        End If
        If rows < row Then
            rows = row
        End If

        shp.Cells(“PinX”).FormulaU = “=” & left + ((col – 1) * wdth)
        shp.Cells(“PinY”).FormulaU = “=” & top – ((row – 1) * hght)
    End If
Next

‘Finally, group them together, and protect the shape
Dim shpMap As Visio.Shape
    Set shpMap = Visio.ActiveWindow.Selection.Group
    shpMap.Cells(“LockGroup”).FormulaU = “=1”
    shpMap.Cells(“LockAspect”).FormulaU = “=1”
    shpMap.Cells(“SelectMode”).FormulaU = “=0”

End Sub

Calibrating the Map Image(s)

We need to ensure that we know the extent of the map image in terms of longitude and latitude in order that we can import any KML file onto it.  Fortunately, my good friend Chris Roth has already pointed the way with his article Map Distance Dimension Line ( http://www.visguy.com/2007/07/13/map-distance-dimension-line/ ). Simply use Chris’s shape between two easily identifiable points on your image…

image

Now, repeat this action in Live Search Maps by drawing a single line between the same geographical points, then name the Map Distance Dimension Line.

image

The line is then added to your collection, and so it will be there when you export the collection to KML.

image

You can already enter the actual length of the line in Visio to use he Map Distance Dimension Line as described by Chris, but we are going to use it get the longitude and latitude of each end.

image

Importing the KML File (part 1)

In order to parse the KML file, you will need to add a reference to Microsoft XML, and I always add Microsoft Scripting Runtime too.

image

Okay, now some VBA code….

Firstly, you need to select the map group shape, followed by the Map Distance Dimension Line shape before calling ReadKMLFile.

The main public Sub ReadKMLFile starts to parse the XML to get hold of the definition of the Map Distance Dimension Line so that it can be compared with the equivalent shape.  It uses these two bits of information to calculate the longitude and latitude extents of the background map.  These details are added the map shape, and the Map Distance Dimension Line is updated with the accurate length.

Public Sub ReadKMLFile()
‘Normally, I would use a FileOpen dialog here….
Dim kmlfile As String
   kmlfile = InputBox(“Enter the path of a KML file”, “Import KML”)
    If Len(kmlfile) = 0 Then
        Exit Sub
    ElseIf Len(Dir(kmlfile)) = 0 Then
        Exit Sub
    End If
Dim xdoc As MSXML2.DOMDocument
    Set xdoc = New MSXML2.DOMDocument
    If xdoc.Load(kmlfile) = False Then
        Exit Sub
    End If
Dim shpMap As Visio.Shape   ‘Map Shape
If Visio.ActiveWindow.Selection.Count = 0 Then
    MsgBox “Please select the map shape”
    Exit Sub
Else
    ‘Assume that the map shape has been selected in Visio
    Set shpMap = Visio.ActiveWindow.Selection.PrimaryItem
End If

‘see http://www.visguy.com/2007/07/13/map-distance-dimension-line/
Dim shpMDDL As Visio.Shape  ‘Map Distance Dimension Line
Dim elmMDDL As MSXML2.IXMLDOMNode    ‘Corresponding KML element
Const MDDLName As String = “Map Distance Dimension Line”
    Set elmMDDL = xdoc.SelectSingleNode(“//kml/Document/Placemark[name='” & MDDLName & “‘]”)
    If Not elmMDDL Is Nothing Then
        ‘There is a calibration node,
        ‘so there should be two shapes selected Map + MDDL
        If Visio.ActiveWindow.Selection.Count <> 2 Then
            MsgBox “Please select the map then the MDL shape”
            Exit Sub
        Else
            Set shpMDDL = Visio.ActiveWindow.Selection.Item(2)
            calibrateMap shpMap, shpMDDL, elmMDDL
        End If
    End If

End Sub

Private Sub calibrateMap(ByVal shpMap As Visio.Shape, _
    ByVal shpMMDL As Visio.Shape, ByVal elmMDDL As MSXML2.IXMLDOMNode)
‘shpMap vars
Dim dWidth As Double
Dim dHeight As Double
Dim dX As Double
Dim dY As Double
Dim dXLeft As Double
Dim dYTop As Double
Dim dXRight As Double
Dim dYBottom As Double
Dim dLonLeft As Double
Dim dLatTop As Double
Dim dLonRight As Double
Dim dLatBottom As Double

‘shpMMDL vars
Dim dPinXBegin As Double
Dim dPinYBegin As Double
Dim dPinXEnd As Double
Dim dPinYEnd As Double
Dim dLength As Double
‘elemMMDL vars
Dim vertexes As Variant
Dim dLonBegin As Double
Dim dLatBegin As Double
Dim dLonEnd As Double
Dim dLatEnd As Double
Dim dDistance As Double ‘KM

‘Scale factor
Dim dRatio As Double
Dim dXRatio As Double
Dim dYRatio As Double
Dim i As Integer

    ‘Get map shape values
    dWidth = shpMap.Cells(“Width”).ResultIU
    dHeight = shpMap.Cells(“Height”).ResultIU
    dXLeft = shpMap.Cells(“PinX”).ResultIU – shpMap.Cells(“LocPinX”).ResultIU
    dYBottom = shpMap.Cells(“PinY”).ResultIU – shpMap.Cells(“LocPinY”).ResultIU
    dYTop = dYBottom + dHeight
    dXRight = dXLeft + dWidth
    ‘Get MMDL shape
    dPinXBegin = shpMMDL.Cells(“BeginX”).ResultIU
    dPinYBegin = shpMMDL.Cells(“BeginY”).ResultIU
    dPinXEnd = shpMMDL.Cells(“EndX”).ResultIU
    dPinYEnd = shpMMDL.Cells(“EndY”).ResultIU
    dLength = shpMMDL.LengthIU
    setCoords elmMDDL, vertexes
    dLonBegin = vertexes(0, 0)
    dLonEnd = vertexes(0, 1)
    dLatBegin = vertexes(UBound(vertexes), 0)
    dLatEnd = vertexes(UBound(vertexes), 1)
    If shpMMDL.CellExists(“Prop.CurrentSize”, Visio.visExistsAnywhere) Then
        shpMMDL.Cells(“Prop.CurrentSize”).FormulaU = “=” & getKMFromDegreesDisp(dLatBegin, dLonBegin, dLatEnd, dLonEnd) & ” km”
    End If
    dDistance = Sqr((dLonEnd – dLonBegin) ^ 2 + (dLatEnd – dLatBegin) ^ 2)
    dRatio = dDistance / dLength
    dXRatio = (dLonEnd – dLonBegin) / (dPinXEnd – dPinXBegin)
    dYRatio = (dLatEnd – dLatBegin) / (dPinYEnd – dPinYBegin)
    dLonLeft = dLonBegin – ((dPinXBegin – dXLeft) * dXRatio)
    dLonRight = dLonLeft + (dWidth * dXRatio)
    dLatBottom = dLatBegin – ((dPinYBegin – dYBottom) * dYRatio)
    dLatTop = dLatBottom + (dHeight * dYRatio)

    setProp shpMap, “MinLon”, “Min Longitude”, “2”, CStr(dLonLeft)
    setProp shpMap, “MinLat”, “Min Latitude”, “2”, CStr(dLatBottom)
    setProp shpMap, “MaxLon”, “Max Longitude”, “2”, CStr(dLonRight)
    setProp shpMap, “MaxLat”, “Max Latitude”, “2”, CStr(dLatTop)
    setProp shpMap, “DistanceX”, “Distance X”, “2”, CStr(getKMFromDegreesDisp(dLatBottom, dLonLeft, dLatBottom, dLonRight)) & ” km”
    setProp shpMap, “DistanceY”, “Distance Y”, “2”, CStr(getKMFromDegreesDisp(dLatBottom, dLonLeft, dLatTop, dLonLeft)) & ” km”
Dim hLink As String
Dim elv As Integer
    elv = 14
Dim dLonCntr As Double
    dLonCntr = (dLonLeft + dLonRight) * 0.5
Dim dLatCntr As Double
    dLatCntr = (dLatTop + dLatBottom) * 0.5

    hLink = “http://maps.live.com/default.aspx?cp=” & Format(dLatCntr, “0.000000”) & “%7c” & Format(dLonCntr, “0.000000”) & “&style=h&lvl=” & elv & “&v=1”

    setHLink shpMap, “Map”, “1”, “Show in Windows Live Local”, “1”, hLink

End Sub

Private Function pi() As Double
    pi = 22 / 7
End Function

Private Function atan2(ys, xs)
‘ Given y and x coords returns atan2
‘ by Jim Deutch, Syracuse, New York
‘http://www.accessmonster.com/Uwe/Forum.aspx/access/102224/SQRT-and-ATAN2-functions-to-MS-Access-2007

Dim theta
   If xs <> 0 Then
       theta = Atn(ys / xs)
       If xs < 0 Then
           theta = theta + pi()
       End If
   Else
       If ys < 0 Then
           theta = 3 * pi() / 2 ’90
       Else
           theta = pi() / 2 ‘270
       End If
   End If
atan2 = theta
End Function

Public Function getKMFromDegreesDisp(ByVal Lat1 As Double, ByVal Long1 As Double, _
    ByVal Lat2 As Double, ByVal Long2 As Double) As Double
    Dim dDistance As Double
        dDistance = 0
    Dim dLat1InRad As Double
        dLat1InRad = Lat1 * (pi() / 180)
    Dim dLong1InRad As Double
        dLong1InRad = Long1 * (pi() / 180)
    Dim dLat2InRad As Double
        dLat2InRad = Lat2 * (pi() / 180)
    Dim dLong2InRad As Double
        dLong2InRad = Long2 * (pi() / 180)
    Dim dLongitude As Double
        dLongitude = dLong2InRad – dLong1InRad
    Dim dLatitude As Double
        dLatitude = dLat2InRad – dLat1InRad
    Dim a As Double
        a = (Sin(dLatitude / 2) ^ 2) + Cos(dLat1InRad) * Cos(dLat2InRad) * (Sin(dLongitude / 2) ^ 2)
    Dim c As Double
        c = 2 * atan2(Sqr(a), Sqr(1 – a))
    Const kEarthRadiusKms As Double = 6376.5
    dDistance = kEarthRadiusKms * c
    getKMFromDegreesDisp = dDistance
End Function
Private Function HexToDecimal(ByVal HexString As String) As Long
Dim x As Long
Dim vDec As Variant
vDec = CDec(0) ‘ decimal type supports up to 27 or 28 positions
For x = 1 To Len(HexString)
    vDec = vDec * 16 + CDec(“&H” & Mid$(HexString, x, 1))
Next x
HexToDecimal = vDec
End Function

Private Sub setProp(ByVal shp As Visio.Shape, _
    ByVal name As String, ByVal label As String, _
    ByVal ptype As String, ByVal value As String)
Dim iRow As Integer

    If shp.SectionExists(Visio.visSectionProp, Visio.visExistsAnywhere) = 0 Then
        shp.AddSection Visio.visSectionProp
    End If

    If shp.CellExistsU(“Prop.” & name, Visio.visExistsAnywhere) = 0 Then
        iRow = shp.AddNamedRow(Visio.visSectionProp, name, 0)
        shp.CellsSRC(Visio.visSectionProp, iRow, Visio.visCustPropsLabel).Formula = “=””” & label & “”””
        shp.CellsSRC(Visio.visSectionProp, iRow, Visio.visCustPropsType).Formula = “=” & ptype
    Else
        iRow = shp.Cells(“Prop.” & name).row
    End If
    shp.CellsSRC(Visio.visSectionProp, iRow, Visio.visCustPropsValue).Formula = “=” & value

End Sub

Private Sub setHLink(ByVal shp As Visio.Shape, _
    ByVal name As String, ByVal default As String, _
    ByVal description As String, ByVal newwin As String, _
    ByVal address As String)
Dim iRow As Integer
    If shp.SectionExists(Visio.visSectionHyperlink, Visio.visExistsAnywhere) = 0 Then
        shp.AddSection Visio.visSectionHyperlink
    End If
    If shp.CellExistsU(“Hyperlink.” & name, Visio.visExistsAnywhere) = 0 Then
       iRow = shp.AddNamedRow(Visio.visSectionHyperlink, name, 0)
       shp.CellsSRC(Visio.visSectionHyperlink, iRow, Visio.visHLinkDefault).Formula = “=” & default
       shp.CellsSRC(Visio.visSectionHyperlink, iRow, Visio.visHLinkDescription).Formula = “=””” & description & “”””
       shp.CellsSRC(Visio.visSectionHyperlink, iRow, Visio.visHLinkNewWin).Formula = “=” & newwin
    Else
        iRow = shp.Cells(“Hyperlink.” & name).row
    End If

    shp.CellsSRC(Visio.visSectionHyperlink, iRow, Visio.visHLinkAddress).Formula = “=””” & address & “”””
End Sub

Private Sub setStyle(ByVal elem As MSXML2.IXMLDOMElement, _
    ByRef dicStyles As Dictionary)
Dim id As String
Dim lineStyleColor As String
Dim lineStyleWidth As String
Dim polyStyleColor As String
Dim aStyle(2) As String
Dim i As Integer
Dim elemsub As MSXML2.IXMLDOMElement
Dim attr As String

    id = elem.Attributes(0).Text

    Set elemsub = elem.SelectSingleNode(“LineStyle”)
    For i = 1 To elemsub.ChildNodes.Length
        attr = elemsub.ChildNodes.Item(i – 1).nodeName
        Select Case attr
            Case “color”
                aStyle(0) = elemsub.ChildNodes.Item(i – 1).Text
            Case “width”
                aStyle(1) = elemsub.ChildNodes.Item(i – 1).Text
        End Select
    Next i

    Set elemsub = elem.SelectSingleNode(“PolyStyle”)
    For i = 1 To elemsub.ChildNodes.Length
        attr = elemsub.ChildNodes.Item(i – 1).nodeName
        Select Case attr
            Case “color”
                aStyle(2) = elemsub.ChildNodes.Item(i – 1).Text
        End Select
    Next i
    dicStyles.Add id, aStyle

End Sub

Private Sub setCoords(ByVal elem As MSXML2.IXMLDOMElement, _
    ByRef vertices As Variant)
Dim coordinates As String
Dim coords As MSXML2.IXMLDOMNodeList
Dim vertexes() As String
Dim vertex() As String
Dim vtcs() As Double
Dim i As Integer

    Set coords = elem.getElementsByTagName(“coordinates”)
    If coords.Length > 0 Then
        coordinates = coords(0).Text
        vertexes = Split(coordinates, ” “)
        For i = 0 To UBound(vertexes)
            vertex = Split(vertexes(i), “,”)
            ReDim Preserve vtcs(1, i)
            vtcs(0, i) = vertex(0)
            vtcs(1, i) = vertex(1)
        Next i
        vertices = vtcs
    End If
End Sub

Private Sub setAttribs(ByVal placemark As MSXML2.IXMLDOMElement, _
    ByRef name As String, ByRef description As String, _
    ByRef styleUrl As String)
Dim attr As String
Dim i As Integer

    name = “”
    description = “”
    styleUrl = “”
    For i = 1 To placemark.ChildNodes.Length
        attr = placemark.ChildNodes.Item(i – 1).nodeName
        Select Case attr
            Case “name”
                name = placemark.ChildNodes.Item(i – 1).Text
            Case “description”
                description = placemark.ChildNodes.Item(i – 1).Text
            Case “styleUrl”
                styleUrl = placemark.ChildNodes.Item(i – 1).Text
        End Select
    Next i
End Sub

So, the result of the first bit of code is a new group shape that contains all of the map tile images, and it has shape data/custom properties for the extents of the world that it covers, and it has a hyperlink to open Maps Live to the centre of it!

image

Next, we’ll import the rest of the shapes….

Filed Under: Geographic, Shape Data, VBA, Visio

Published on August 31, 2008 by David Parker

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
Dim
urlOld As String
Dim
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

Filed Under: Hyperlinks, VBA, Visio

  • « Go to Previous Page
  • Go to page 1
  • Interim pages omitted …
  • Go to page 61
  • Go to page 62
  • Go to page 63
  • Go to page 64
  • Go to page 65
  • Interim pages omitted …
  • Go to page 67
  • Go to Next Page »

Primary Sidebar

  • LinkedIn
  • Twitter

Recent Posts

  • A Visio List Shape is also a Container
  • Taking Visio Actions Rows to the limit
  • TimeTable at RMConnect 2022
  • Custom Shapes in Visio in M365 and Web
  • A Multi-Time Zone Clock for Visio

Categories

Tags

Accessibility Add-Ins Containers Data Export Data Graphics Data Import Data Visualizer Educational Excel GraphDatabase Hyperlinks Icon Sets JavaScript Layers Legend Link Data to Shapes Lists MSIgnite MVP Office365 Org Chart PowerApps PowerBI PowerQuery Processes Shape Data Shape Design ShapeSheet ShapeSheet Functions SharePoint 2013 SQL Teams Themes Validation VBA Video Visio Visio 2007 Visio 2013 Visio for the Web Visio Online Visio Pro for Office365 Visio Services Visio Viewer Webinar

Footer

bVisual Profile

The UK-based independent Visio consultancy with a worldwide reach. We have over 25 years experience of providing data visualization solutions to companies around the globe.

Learn more about bVisual

  • LinkedIn
  • Twitter

Search this website

Recent posts

  • A Visio List Shape is also a Container
  • Taking Visio Actions Rows to the limit
  • TimeTable at RMConnect 2022
  • Custom Shapes in Visio in M365 and Web
  • A Multi-Time Zone Clock for Visio

Copyright © 2022 · Executive Pro on Genesis Framework · WordPress · Log in