Question DropManyLinkedU - making addin for visio

rezance

Member
Joined
Dec 13, 2012
Messages
8
Programming Experience
1-3
I am working on my diploma work. The goal is to create addin in visio that should be able to load data from access and vizualize them. I am working in visual studio 2010.
I have problem with one sub (the most important:D), which should take data from visio.datarecordset a draw them on active page.

i tried do it this way Page.DropManyLinkedU Method (Visio)
My version looks like this:
VB.NET:
Private Sub DrawDataset()
        Dim avarObjects(0 To 2) As Object
        Dim adblXYs(0 To 5) As Double
        Dim alngDataRowIDs(0 To 2) As Long
        Dim alngShapeIDs() As Long
        Dim vsoDataRecordset As Visio.DataRecordset
        Dim intRecordesetCount As Integer
        Dim lngReturned As Long
        Dim intCounter As Integer

        intRecordesetCount = pjVis.Application.ActiveDocument.DataRecordsets.Count
        vsoDataRecordset = pjVis.Application.ActiveDocument.DataRecordsets(intRecordesetCount)

        adblXYs(0) = 2
        adblXYs(1) = 2
        adblXYs(2) = 4
        adblXYs(3) = 4
        adblXYs(4) = 6
        adblXYs(5) = 6

        alngDataRowIDs(0) = 1
        alngDataRowIDs(1) = 2
        alngDataRowIDs(2) = 3


        pjVis.Application.ActivePage.DropManyLinkedU(ObjectsToInstance:=appVis.Documents("BASIC_M.VSS").Masters.ItemU("Rectangle"), XYs:=adblXYs, DataRecordsetID:=1, DataRowIDs:=alngDataRowIDs, ApplyDataGraphicAfterLink:=False, ShapeIDs:=alngShapeIDs)

    End Sub
but it doesnt work. Error looks like:
IvalidCastException was unhandled by user code
Unable to cast COM object of type 'Microsoft.Office.Interop.Visio.MasterClass' to class type 'System.Array'. Instances of types that represent COM components cannot be cast to types that do not represent COM components; however they can be cast to interfaces as long as the underlying COM component supports QueryInterface calls for the IID of the interface.

version with DropLinked works fine, but i like to use DropManyLinkedU.
What am i doing wrong?:/ what that error mean?
There is some conversion problem...or what
 
VB.NET:
Dim avarObjects(0 To 2) As Object
        Dim adblXYs(0 To 5) As Double
        Dim alngDataRowIDs(0 To 2) As Integer
        Dim alngShapeIDs() As integer
        Dim vsoDataRecordset As Visio.DataRecordset
        Dim intRecordsetCount As Integer

        intRecordsetCount = pjVis.DataRecordsets.Count
        vsoDataRecordset = pjVis.DataRecordsets(intRecordsetCount)

        avarObjects(0) = appVis.Documents("BASIC_M.VSS").Masters.ItemU("Rectangle")
        avarObjects(1) = appVis.Documents("BASIC_M.VSS").Masters.ItemU("Rectangle")
        avarObjects(2) = appVis.Documents("BASIC_M.VSS").Masters.ItemU("Rectangle")


        adblXYs(0) = 2
        adblXYs(1) = 2
        adblXYs(2) = 4
        adblXYs(3) = 4
        adblXYs(4) = 6
        adblXYs(5) = 6

        alngDataRowIDs(0) = 1
        alngDataRowIDs(1) = 2
        alngDataRowIDs(2) = 3



pjVis.Application.ActivePage.DropManyLinkedU(avarObjects, XYs:=adblXYs, DataRecordsetID:=vsoDataRecordset.ID, DataRowIDs:=alngDataRowIDs, ApplyDataGraphicAfterLink:=False, ShapeIDs:=alngShapeIDs)
VB6/VBA data type Variant isnot supported in VB.Net, we need to use Object
VB6/VBA data type Long is data type Integer in VB.Net
Thx for help

source Integer Data Type for Visual Basic 6.0 Users
 
Back
Top