2010-12-01 58 views
1

我使用Visio 2007來繪製組織結構圖。
一切工作正常,但我對如何在下面的命名空間C#+ Visio 2007集成

Microsoft.Office.Interop.Visio.Shape 

任何幫助將是非常讚賞訪問並設置形狀對象的屬性問題。

回答

0

你想要做什麼?以下是我如何設置形狀的文本屬性。

using Visio = Microsoft.Office.Interop.Visio; 

[...] (some code) 

Visio.Shape shape1 = page.Drop(currentStencil.Masters["Start/End"], 1.50, 1.50); 
shape1.Text = "John"; 
+0

謝謝您的回覆。但我確切需要的是設置形狀的自定義屬性,而不是文本屬性。 – 2010-12-01 10:14:14

1

Visio廣泛使用了一種稱爲細胞的東西,它類似於Excel細胞。 要從形狀得到一個單元格引用:

Visio.Cell aCell = shape1.Cells("Prop.XXXX"); 

XXXX是屬性的名稱。 要獲取單元格的值:

aCell.FormulaU 
2

它可以幫助不僅是你,但別人太.. :)

進口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 

結束等級