2 Replies Latest reply on Nov 19, 2012 6:26 PM by Sean Fagan

    Is anyone using Miscroft Visio to plot x y coordinates?

    Sean Fagan

      During weekly Tableau training sessions the host of the webinar usually mentions that Visio is a more efficient way to plot x y coordinates on an image versus manually discovering and entering them into excel by typing.

       

      Is anyone doing this?  Tableau provides no support for Visio [which is fair enough] but they also have no information they can point me to.

       

      Would anyone mind sharing if they have done this and some simple steps?  Visio is new to me.

       

      Thanks in advance.

        • 1. Re: Is anyone using Miscroft Visio to plot x y coordinates?
          Russell Christopher

          Morning, Sean

           

          Here is the basic approach most folks will take.

           

          I'm including some pointers to Microsoft help topics along the way which will hopefully help you get started.

           

          When all is said and done, you'll probably need to spend time in the Microsoft Forums to get this all working if you're a neophyte Macro/Code writer in Office applications...but at least now you'll know what questions to ask.

           

          Basic approach:

           

           

          How do you create a Macro?

           

          • Make sure the "Developer" toolbar or ribbon is displayed. Based on the version of Visio you're running, there are different ways to turn it on - please Google something like "Visio Developer Toolbar <your version>" or some such to find the instructions you need
          • On the Developer Toolbar, click Visual Basic
          • Right-click the Visio Objects folder and choose Insert | Module
          • Add a procedure which will spit out points. Here's a sample written by my colleague Alan E. about a year ago:

           

          Public Sub WriteTableauPointsFile()

              Dim oShape As Visio.Shape

              Dim oPath As Visio.Path

              Dim oPoints() As Double

                 

              'Set the output file to be the same as the source file, but .CSV

              oFileName = Left(ActiveDocument.FullName, Len(ActiveDocument.FullName) - 3) & "csv"

             

              'Set the separator character

              oSeparator = "|"

             

              'If file already exists, delete it

              If Dir(oFileName) <> "" Then

                  Kill oFileName

              End If

             

              'Open the output file and write the header line

              oFile = FreeFile

              Open oFileName For Append As #oFile

              Print #oFile, "ShapeNo" & oSeparator & "ShapeName" & oSeparator & "PathNo" & oSeparator & "PointNo" & oSeparator & "X" & oSeparator & "Y"

             

              'Get all the shapes on the page

              ActiveWindow.SelectAll

              Set oShapes = ActiveWindow.Selection

           

           

              'Cycle through the shapes

              For Each oShape In oShapes

                 

                  'Shapes can have multiple paths

                  For j = 1 To oShape.Paths.Count

                      Set oPath = oShape.Paths(j)

                     

                      'Enumerate the points in each path with 0.5 sensitivity for curves

                      oPath.Points 0.5, oPoints

                      i = 0

                      Do While i < UBound(oPoints)

                          x = Int(oPoints(i))

                          y = Int(oPoints(i + 1))

                          i = i + 2

                         

                          'Write the record for each point

                          Print #oFile, oShape.Index; oSeparator; oShape.Text; oSeparator; j; oSeparator; i; oSeparator; x; oSeparator; y

                      Loop

                  Next j

              Next

             

              'Close the file and exit

              Close #oFile

          End Sub

           

          You run the procedure above by using the Macros button on the Developer Toolbar.

           

          Good luck!