I have in past an application that generate the Organizational Chart of a company, on Visio 2007 But now when i have installed Visio 2013/2016 the code didn
Inappropriate target object for this action.
What I have tried:
the exception was thrown when i want to change the text of a shape, Below are my code:
Dim vApp As Microsoft.Office.Interop.Visio.Application
Dim vDoc As Microsoft.Office.Interop.Visio.Document
Dim vFromShape As Microsoft.Office.Interop.Visio.Shape
Dim vToShape As Microsoft.Office.Interop.Visio.Shape
Dim vFlowChartMaster As Microsoft.Office.Interop.Visio.Master
Dim vStencil As Microsoft.Office.Interop.Visio.Document
Dim dblXLocation As Double
Dim dblYLocation As Double
Dim TEMPLATEPATH = genInfo.templatesDirectory & "ORGCH_M.VSS"
Dim vApp As Microsoft.Office.Interop.Visio.Application
Dim vDoc As Microsoft.Office.Interop.Visio.Document
Dim vFromShape As Microsoft.Office.Interop.Visio.Shape
Dim vToShape As Microsoft.Office.Interop.Visio.Shape
Dim vFlowChartMaster As Microsoft.Office.Interop.Visio.Master
Dim vStencil As Microsoft.Office.Interop.Visio.Document
Dim dblXLocation As Double
Dim dblYLocation As Double
Dim TEMPLATEPATH = genInfo.templatesDirectory & "ORGCH_M.VSS"
Dim tblOC As DataTable = GetOrganizationalChartReport(Entity, AccEntity, Division, Department, Unit)
If tblOC IsNot Nothing AndAlso tblOC.Rows.Count > 0 Then
vFlowChartMaster = vStencil.Masters(tblOC.Rows(0)!shape)
vToShape = vApp.ActivePage.Drop(vFlowChartMaster, dblXLocation, dblYLocation)
vToShape.Text = String.Format("{0} {1}{2}{3}{4}", tblOC.Rows(0)!fullname, Environment.NewLine, tblOC.Rows(0)!Department, _
Environment.NewLine, tblOC.Rows(0)!jobtitle)
Dim UndoScopeID1, UndoScopeID2 As Long
UndoScopeID1 = vApp.BeginUndoScope("Size Object")
UndoScopeID2 = vApp.BeginUndoScope("Size Object")
vApp.ActiveWindow.Page.Shapes.ItemFromID(vToShape.ID).CellsSRC(visSectionObject, visRowXFormOut, visXFormHeight).FormulaForceU = "15 mm"
vApp.EndUndoScope(UndoScopeID1, True)
vApp.ActiveWindow.Page.Shapes.ItemFromID(vToShape.ID).CellsSRC(visSectionObject, visRowXFormOut, visXFormWidth).FormulaU = "30 mm"
vApp.EndUndoScope(UndoScopeID2, True)
Reportsto = tblOC.Rows(0)!Unique_ID
functionalSup = tblOC.Rows(0)!functionalSup
vFromShape = vToShape
Dim MSVisioShapeObj As New MSVisioShape(vFromShape.ID, vToShape.ID, tblOC.Rows(0)!Unique_ID, tblOC.Rows(0)!Reports_to, tblOC.Rows(0)!FunctionalSup)
functionalShapeslst.Add(MSVisioShapeObj)
vToShape = Nothing
Call AddSubOrdinates(Reportsto, functionalSup, vApp, vFromShape, vStencil, dblXLocation, dblYLocation, vDoc, functionalShapeslst, Entity, AccEntity)
End If
The exception is thrown in the below line of code:
vToShape.Text = String.Format("{0} {1}{2}{3}{4}", tblOC.Rows(0)!fullname, Environment.NewLine, tblOC.Rows(0)!Department, Environment.NewLine, tblOC.Rows(0)!jobtitle)
is there anything changed in the newly version of Visio ?