BB code in posts seems to be working again!
I haven't turned on every single tag, so please let me know if there are any that are used/needed but not activated.

Main Menu

Macro Visio 2010 does not work in Visio 2013

Started by willdthrill, June 27, 2018, 07:01:45 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.


Hello - just upgraded from Visio 2010 to Visio 2013.  The following macro now fails (Run-time error -2032465751 (86db08a9).

The below updates all the off sheet reference shape's DESTINATION SHEET shape data to the current linked page.

Sub FixOffPageReferences()

Dim OPCDShapeID As String
Dim OPCDPageName As String
Dim pag2 As Visio.Page
    For Each pag In Application.ActiveDocument.Pages
        'Only the foreground pages
        If pag.Type = visTypeForeground Then
            'Loop through all shapes in page
            For Each shp In pag.Shapes
                'Make sure shape exists (Script crashes if it tries to read data that doesn't exist)
                If shp.CellExists("Prop.Row_1", 0) Then
                    deviceType = shp.Cells("Prop.Row_1.Label").ResultStr(visNoCast)
                    If deviceType = "DESTINATION SHEET" Then
                        OPCShapeID = shp.Cells("User.OPCShapeID").ResultStr(visNoCast)
                        OPCDShapeID = shp.Cells("User.OPCDShapeID").ResultStr(visNoCast)
                        'make sure the OPC is connected to a destination shape on another sheet
                        If OPCDShapeID <> "" Then
                            For Each pag2 In Application.ActiveDocument.Pages
                                If pag2.Type = visTypeForeground Then
                                    If pag2.Shapes.ItemFromUniqueID(OPCDShapeID).Name <> "Sheet.0" Then  <---fails here
                                        SecondPageName = pag2.Name
                                        pag2.Shapes(OPCDShapeID).Cells("User.OPCDPageID").Formula = Chr(34) & pag.PageSheet.UniqueID(visGetOrMakeGUID) & Chr(34)
                                        Exit For
                                    End If
                                End If
                        End If
                        shp.CellsSRC(visSectionHyperlink, 0, visHLinkSubAddress).FormulaU = Chr(34) & SecondPageName & Chr(34)
                        On Error Resume Next
                        shp.Cells("Prop.Row_1").FormulaU = "=Guard(Hyperlink.OffPageConnector.SubAddress)"
                        On Error GoTo 0
                    End If
                End If
        End If
    MsgBox "All Sheet numbers on off-sheet references have been updated."

End Sub


Browser ID: smf (possibly_robot)
Templates: 4: index (default), Display (default), GenericControls (default), GenericControls (default).
Sub templates: 6: init, html_above, body_above, main, body_below, html_below.
Language files: 4: index+Modifications.english (default), Post.english (default), Editor.english (default), Drafts.english (default).
Style sheets: 4: index.css, attachments.css, jquery.sceditor.css, responsive.css.
Hooks called: 140 (show)
Files included: 34 - 1306KB. (show)
Memory used: 1053KB.
Tokens: post-login.
Cache hits: 14: 0.00220s for 26,764 bytes (show)
Cache misses: 3: (show)
Queries used: 15.

[Show Queries]