{"id":3320,"date":"2014-12-04T08:45:27","date_gmt":"2014-12-04T08:45:27","guid":{"rendered":"http:\/\/blog.bachi.net\/?p=3320"},"modified":"2014-12-04T11:51:55","modified_gmt":"2014-12-04T11:51:55","slug":"visio-2013-visual-basic-for-applications","status":"publish","type":"post","link":"https:\/\/blog.bachi.net\/?p=3320","title":{"rendered":"Visio 2013 Visual Basic for Applications"},"content":{"rendered":"<p><a href=\"http:\/\/visio.mvps.org\/\">VisioMVP<\/a><br \/>\n<a href=\"http:\/\/www.visguy.com\/\">VisioGuy<\/a><\/p>\n<p><a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/office\/ee861526%28v=office.15%29.aspx\">Visio 2013 Automation reference<\/a><br \/>\n<a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/office\/ff766851%28v=office.15%29.aspx\">Application.ActiveWindow<\/a><br \/>\n<a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/office\/ff766487%28v=office.15%29.aspx\">Window<\/a><br \/>\n<a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/office\/ff768546%28v=office.15%29.aspx\">Shape<\/a><br \/>\n<a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/office\/ff768737%28v=office.15%29.aspx\">Selection<\/a><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nPublic Sub AddConnectionPoint()\r\n    Dim selectedShapes  As Selection\r\n    Dim theShape        As Shape\r\n    Dim index           As Integer\r\n    Dim rowNumber       As Integer\r\n    \r\n    Set selectedShapes = ActiveWindow.Selection\r\n    \r\n    For index = 1 To selectedShapes.Count\r\n        Set theShape = selectedShapes.Item(index)\r\n        \r\n        ' If there is no 'Connection Points' section, create one for the shape\r\n        If theShape.SectionExists(Visio.visSectionConnectionPts, 1) = False Then\r\n            theShape.AddSection (Visio.visSectionConnectionPts)\r\n        End If\r\n        \r\n        ' Add a new row to the 'Connection Points' section\r\n        rowNumber = theShape.AddRow(Visio.visSectionConnectionPts, Visio.visRowConnectionPts, Visio.VisRowTags.visTagCnnctPt)\r\n        theShape.CellsSRC(Visio.visSectionConnectionPts, Visio.visRowConnectionPts, Visio.visX).Formula = &quot;=0&quot;\r\n        theShape.CellsSRC(Visio.visSectionConnectionPts, Visio.visRowConnectionPts, Visio.visY).Formula = &quot;=Height\/2&quot;\r\n        \r\n        rowNumber = theShape.AddRow(Visio.visSectionConnectionPts, Visio.visRowConnectionPts, Visio.VisRowTags.visTagCnnctPt)\r\n        theShape.CellsSRC(Visio.visSectionConnectionPts, Visio.visRowConnectionPts, Visio.visX).Formula = &quot;=Width\/2&quot;\r\n        theShape.CellsSRC(Visio.visSectionConnectionPts, Visio.visRowConnectionPts, Visio.visY).Formula = &quot;=0&quot;\r\n        \r\n        rowNumber = theShape.AddRow(Visio.visSectionConnectionPts, Visio.visRowConnectionPts, Visio.VisRowTags.visTagCnnctPt)\r\n        theShape.CellsSRC(Visio.visSectionConnectionPts, Visio.visRowConnectionPts, Visio.visX).Formula = &quot;=Width&quot;\r\n        theShape.CellsSRC(Visio.visSectionConnectionPts, Visio.visRowConnectionPts, Visio.visY).Formula = &quot;=Height\/2&quot;\r\n        \r\n        rowNumber = theShape.AddRow(Visio.visSectionConnectionPts, Visio.visRowConnectionPts, Visio.VisRowTags.visTagCnnctPt)\r\n        theShape.CellsSRC(Visio.visSectionConnectionPts, Visio.visRowConnectionPts, Visio.visX).Formula = &quot;=Width\/2&quot;\r\n        theShape.CellsSRC(Visio.visSectionConnectionPts, Visio.visRowConnectionPts, Visio.visY).Formula = &quot;=Height&quot;\r\n        \r\n        rowNumber = theShape.AddRow(Visio.visSectionConnectionPts, Visio.visRowConnectionPts, Visio.VisRowTags.visTagCnnctPt)\r\n        theShape.CellsSRC(Visio.visSectionConnectionPts, Visio.visRowConnectionPts, Visio.visX).Formula = &quot;=(Width\/2)  * (1 + cos(45 deg))&quot;\r\n        theShape.CellsSRC(Visio.visSectionConnectionPts, Visio.visRowConnectionPts, Visio.visY).Formula = &quot;=(Height\/2) * (1 + cos(45 deg))&quot;\r\n        \r\n        rowNumber = theShape.AddRow(Visio.visSectionConnectionPts, Visio.visRowConnectionPts, Visio.VisRowTags.visTagCnnctPt)\r\n        theShape.CellsSRC(Visio.visSectionConnectionPts, Visio.visRowConnectionPts, Visio.visX).Formula = &quot;=(Width\/2)  * (1 - cos(45 deg))&quot;\r\n        theShape.CellsSRC(Visio.visSectionConnectionPts, Visio.visRowConnectionPts, Visio.visY).Formula = &quot;=(Height\/2) * (1 + cos(45 deg))&quot;\r\n        \r\n        rowNumber = theShape.AddRow(Visio.visSectionConnectionPts, Visio.visRowConnectionPts, Visio.VisRowTags.visTagCnnctPt)\r\n        theShape.CellsSRC(Visio.visSectionConnectionPts, Visio.visRowConnectionPts, Visio.visX).Formula = &quot;=(Width\/2)  * (1 + cos(45 deg))&quot;\r\n        theShape.CellsSRC(Visio.visSectionConnectionPts, Visio.visRowConnectionPts, Visio.visY).Formula = &quot;=(Height\/2) * (1 - cos(45 deg))&quot;\r\n        \r\n        rowNumber = theShape.AddRow(Visio.visSectionConnectionPts, Visio.visRowConnectionPts, Visio.VisRowTags.visTagCnnctPt)\r\n        theShape.CellsSRC(Visio.visSectionConnectionPts, Visio.visRowConnectionPts, Visio.visX).Formula = &quot;=(Width\/2)  * (1 - cos(45 deg))&quot;\r\n        theShape.CellsSRC(Visio.visSectionConnectionPts, Visio.visRowConnectionPts, Visio.visY).Formula = &quot;=(Height\/2) * (1 - cos(45 deg))&quot;\r\n        \r\n    Next\r\nEnd Sub\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>VisioMVP VisioGuy Visio 2013 Automation reference Application.ActiveWindow Window Shape Selection Public Sub AddConnectionPoint() Dim selectedShapes As Selection Dim theShape As Shape Dim index As Integer Dim rowNumber As Integer Set selectedShapes = ActiveWindow.Selection For index = 1 To selectedShapes.Count Set theShape = selectedShapes.Item(index) &#8216; If there is no &#8216;Connection Points&#8217; section, create one for the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3320","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/posts\/3320","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3320"}],"version-history":[{"count":4,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/posts\/3320\/revisions"}],"predecessor-version":[{"id":3324,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/posts\/3320\/revisions\/3324"}],"wp:attachment":[{"href":"https:\/\/blog.bachi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3320"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3320"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3320"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}