Visio Guy

Visio Discussions => Programming & Code => Topic started by: perry59 on April 16, 2024, 03:23:17 PM

Title: visio recordsets
Post by: perry59 on April 16, 2024, 03:23:17 PM
I am using some code I obtained from someone else and one of it's functions is to extract data from a recordset and insert it into a table however the moment it tries to do so I get an exception that states:
"This operation is not supported in Microsoft Visio Standard 2010."
But I am using visio 2016"
here is the code snippet:
 Try
            Select Case arg
                Case 0, 1 : FlagPage = arg : dlgNew = New dlgTableSize
                Case 2 : dlgNew = New dlgFromFile
                Case 3
                    If vsoApp.ActiveDocument.DataRecordsets.Count = 0 Then '<-bombs here
                        MsgBox("There are no external data connections available in the active document.", vbCritical, "Error")

                    End If
                    dlgNew = New dlgLinkData
                Case 4 : dlgNew = New dlgIntellInput
                Case 5 : dlgNew = New dlgPictures
                Case 6 : dlgNew = New dlgSelectFromList
                Case 7 : dlgNew = New dlgSortTable
            End Select

            dlgNew.ShowDialog()
            dlgNew = Nothing
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
Does anyone have any clue on how to fix this?
Thanks
Title: Re: visio recordsets
Post by: Thomas Winkel on April 16, 2024, 06:18:34 PM
External Data is not supported by Visio Standard.
You need Professional (or maybe 365 / Plan 2).

Try that in VBA:
Sub DrsTest()
    Debug.Print ActiveDocument.DataRecordsets.Count
End Sub
This should give the same error for your installation.
Title: Re: visio recordsets
Post by: perry59 on April 16, 2024, 07:52:11 PM
Indeed if I run that code in the VBA editor I get the same thing. Since the error message didn't even get my visio version right I was a bit skeptical of it.
I have a pro version at home, I'll see what happens there.
Thanks
Title: Re: visio recordsets
Post by: Yacine on April 17, 2024, 06:09:35 AM
But you don't need to rely on Visio's datarecordsets, you can use VBA's functions to connect directly with external datasets (Excel, databases, ...)
Title: Re: visio recordsets
Post by: Nikolay on April 17, 2024, 09:09:08 AM
Probably they just haven't updated the error message since Visio 2010.
Title: Re: visio recordsets
Post by: perry59 on April 17, 2024, 07:57:01 PM
I don't get that error when I run it at home with the pro version, I just get an error there is no data. Now I'll have to relearn how to connect visio to external data. :)