Visio VBA Macro: I wish to set the value of a shapes shape data after the shape has been dropped onto the page by the program. I created a hex shape with 5 defined data shape strings.
I have tried searching for answers but have found no clear instructions on how to do this
Dim strConnection As String
Dim strCommand As String
Dim strOfficePath As String
Dim cellString As String
Dim vsoDataRecordset As Visio.DataRecordset
Dim vsoCell As Visio.Cell
strOfficePath = Visio.Application.Path
strConnection = "Provider=Microsoft.ACE.OLEDB.12.0;" _
& "User ID=Admin;" _
& "Data Source=svs2.XLSX;" _
& "Mode=Read;" _
& "Extended Properties=""HDR=YES;IMEX=1;MaxScanRows=0;Excel 12.0;"";" _
& "Jet OLEDB:Engine Type=34;"
strCommand = "SELECT * FROM [BaseTemplate$]"
Set vsoDataRecordset = ActiveDocument.DataRecordsets.Add(strConnection, strCommand, 0, "Data")
MsgBox "Connected Up:" & vsoDataRecordset.DataColumns(1)
'Get the row IDs of all the rows in the data recordset
lngRowIDs = vsoDataRecordset.GetDataRowIDs("")
'Iterate through all the records in the data recordset.
For lngRow = LBound(lngRowIDs) + 1 To UBound(lngRowIDs) + 1
varRowData = vsoDataRecordset.GetRowData(lngRow)
'varRowData = vsoDataReco
'Drop Shape onto page
Set shpObject = pagThisPage.Drop(Application.Documents("microservices V2.VSS").Masters("Microservice"), 0#, 0#)
'Update Shapes Text
shpObject.Text = varRowData(0)
'Get cell that i want to update
Set vsoCell = shpObject.Cells("Prop.Object")
'Copy data i want to apply to shape to string
cellString = varRowData(0)
vsoCell.Formula = cellString
'get shape data value to print out
dt = shpObject.Cells("Prop.Object").ResultStr("")
MsgBox "---" & dt & ":" & vsoCell.Formula
Next lngRow