【发布时间】:2012-11-26 23:32:25
【问题描述】:
我正在使用 Visio 2007 来绘制组织结构图。
一切正常,但我在如何访问和设置以下命名空间中的形状对象的属性时遇到问题
Microsoft.Office.Interop.Visio.Shape
任何帮助将不胜感激。
【问题讨论】:
我正在使用 Visio 2007 来绘制组织结构图。
一切正常,但我在如何访问和设置以下命名空间中的形状对象的属性时遇到问题
Microsoft.Office.Interop.Visio.Shape
任何帮助将不胜感激。
【问题讨论】:
它不仅可以帮助你,也可以帮助其他人.. :)
导入 Microsoft.Office.Interop.Visio 公共类 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
结束类
【讨论】:
Visio 广泛使用了类似于 excel 单元格的单元格。 从形状中获取单元格引用:
Visio.Cell aCell = shape1.Cells("Prop.XXXX");
XXXX 是属性的名称。 获取单元格的值:
aCell.FormulaU
【讨论】:
你到底想做什么?这是我设置形状的文本属性的方法。
using Visio = Microsoft.Office.Interop.Visio;
[...] (some code)
Visio.Shape shape1 = page.Drop(currentStencil.Masters["Start/End"], 1.50, 1.50);
shape1.Text = "John";
【讨论】: