C# + Visio 2007 integration
I am using Visio 2007 in order to draw the organization chart.
Everything is working fine, but i have a problem on how to access and set the properties of the shape object in the below namespaceMicrosof开发者_开发知识库t.Office.Interop.Visio.Shape
Any help will be very appreciated.
It may help not only you but others too.. :)
Imports Microsoft.Office.Interop.Visio Public Class VisioMain
Dim currentStencil As Document
Dim currentPage As Page
Private Sub VisioMain_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
currentPage = DC.Document.Pages(1)
SetLandscape(currentPage)
currentStencil = DC.Document.Application.Documents.OpenEx("Rack-mounted Equipment (US units).VSS", VisOpenSaveArgs.visOpenDocked)
Dim stencilWindow As Window
stencilWindow = currentPage.Document.OpenStencilWindow
stencilWindow.Activate()
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
''Code to get individual property of Shape...........!
For Each objShape As Microsoft.Office.Interop.Visio.Shape In currentPage.Shapes
TextBox1.Text = objShape.Cells("Prop.Height").ResultStr("text")
Next
''.............!
End Sub
End Class
Visio makes extensive use of something called a cell which is similar to excel cells. To get a cell reference from a shape:
Visio.Cell aCell = shape1.Cells("Prop.XXXX");
XXXX is the name of the property. To get the value of the cell:
aCell.FormulaU
What are you trying to do exactly? Here is how I set the text property of a shape.
using Visio = Microsoft.Office.Interop.Visio;
[...] (some code)
Visio.Shape shape1 = page.Drop(currentStencil.Masters["Start/End"], 1.50, 1.50);
shape1.Text = "John";
精彩评论