Page.DropLinked method

K

Kaego

I am trying to find some examples on using the Page.DropLinked method with VBA.

I am getting an "invalid parameter" Run-Time error -2032465751 with the
following example in the Visio SDK

Public Sub DropLinked_Example()

Dim vsoShape As Visio.Shape
Dim vsoMaster As Visio.Master
Dim dblX As Double
Dim dblY As Double
Dim lngDataRowID As Long
Dim vsoDataRecordset As Visio.DataRecordset
Dim intRecordesetCount As Integer

intRecordsetCount = Visio.ActiveDocument.DataRecordsets.Count
Set vsoDataRecordset =
Visio.ActiveDocument.DataRecordsets(intRecordsetCount)

Set vsoMaster = Visio.Documents("Basic_U.VSS").Masters("Rectangle")
dblX = 2
dblY = 2
lngDataRowID = 1

Set vsoShape = ActivePage.DropLinked(vsoMaster, dblX, dblY,
vsoDataRecordset.ID, lngDataRowID, True)

End Sub
 
A

AlEdlund

so, which instruction failed and which parameter was invalid? (single step
in debug mode while watching the local variables window)

Your example code never tests to see if the stencil is loaded,
datarecordsets exist in the document, or recordeset count is gt 0.......

al
 
K

Kaego

Hi Al,

Thank you for the reply.

Stepping throught the sample code I find it is the "Set vsoShape" statement
fails. Doing into debug mode is see all of the parameters hold values, so I
am not sure which is invalid. How would I check thing further?

I understand that this code doesn't provide any error checking I am just
trying to get the DropLinked function to do anything. Once I able able to get
it going I will put proper error handling around it.

Any additional help you can provide would be most appreciated.

K
 
K

Kaego

Wow Al,

Thank you for taking a look!!

I'll have to figure out how to get your attachment - I'm not seeing it from
the Microsoft communities site.

I'll pull it and give it a try. Thank you again!!
 
K

Kaego

Hi Al,

I may have mis-understood your post. Did you attach a drawing to your post
or are you referring to the code I posted in the first post of this thread.
I'm not able to find any attachment. Would you please clarify.

What demo from the SDK did you use?

K
 
A

AlEdlund

K,
Yes I did attempt to post the drawing, it appears to not have been added.
I'm using the v2010 sdk which has a vba section of code samples. The demo is
data connectivity - drop-linked specific rows. The demo calls a subroutine
that is not illustrated (had to convert from c# to vba). Here's the added
routine for the demo.
al


Public Function RetrieveDataRecordset _
(ByVal vsoTargetDocument As Visio.Document) _
As Visio.DataRecordset

Dim returnValue As Visio.DataRecordset
Set returnValue = Nothing
Dim excelDataSourceLocation As String
Dim excelDataSourceName As String
Dim excelCommandString As String
Dim excelConnectionString As String

' Build the path to the localized version of ORGDATA.XLS.
excelDataSourceName = "ORGDATA.XLS"
'excelDataSourceLocation = (vsoTargetDocument.Application.Path &
"Visio Content\") + vsoTargetDocument.Application.Language & "\"
excelDataSourceLocation = "c:\Program Files (x86)\Microsoft
Office\Office14\Visio Content\1033\"

Dim file As String
file = excelDataSourceLocation & excelDataSourceName

' do not forget to reference microsoft script runtime
Set fso = CreateObject("Scripting.FileSystemObject")
If Not fso.FileExists(file) Then
MsgBox file & " was not located.", vbInformation, "File Not
Found"
Else
MsgBox file & " has been located.", vbInformation, "File Found"
End If


' Build a connection string to the data source.
excelCommandString = "SELECT * FROM `Sheet1$`"
excelConnectionString = ("Provider=Microsoft.ACE.OLEDB.12.0;User
ID=Admin;" & "Data Source=") + excelDataSourceLocation + excelDataSourceName
& ";" & "Mode=Read;Extended Properties=""HDR=YES;IMEX=1;" &
"MaxScanRows=0;Excel 8.0;"";" & "Jet OLEDB:Engine Type=34;"

' Create a new recordset named "Organization Chart" and return
' it to the calling method.
Set returnValue =
vsoTargetDocument.DataRecordsets.Add(excelConnectionString,
excelCommandString, 0, "Organization Chart")

Set RetrieveDataRecordset = returnValue

End Function
 
K

Kaego

Super - thank you so much - have not converted from C# to VBA before so I
sincerely appreciate your help!!!!

I can't wait to give it a try

K
 
A

AlEdlund

The demo is vba, it just referenced a routine that had to be used and the
routine was from a different (c#) demo. I added the test in the file load to
make sure the external file existed (and hardcoded it for the location on my
system) but that's a no-brainer to fix.
al
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top