【问题标题】:C# + Visio 2007 integrationC# + Visio 2007 集成
【发布时间】:2012-11-26 23:32:25
【问题描述】:

我正在使用 Visio 2007 来绘制组织结构图。
一切正常,但我在如何访问和设置以下命名空间中的形状对象的属性时遇到问题

Microsoft.Office.Interop.Visio.Shape

任何帮助将不胜感激。

【问题讨论】:

    标签: c# visio


    【解决方案1】:

    它不仅可以帮助你,也可以帮助其他人.. :)

    导入 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
    

    结束类

    【讨论】:

      【解决方案2】:

      Visio 广泛使用了类似于 excel 单元格的单元格。 从形状中获取单元格引用:

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

      XXXX 是属性的名称。 获取单元格的值:

      aCell.FormulaU 
      

      【讨论】:

        【解决方案3】:

        你到底想做什么?这是我设置形状的文本属性的方法。

        using Visio = Microsoft.Office.Interop.Visio;
        
        [...] (some code)
        
        Visio.Shape shape1 = page.Drop(currentStencil.Masters["Start/End"], 1.50, 1.50);
        shape1.Text = "John";
        

        【讨论】:

        • 感谢您的回复。但我真正需要的是设置形状的自定义属性,而不是文本属性。
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2013-08-21
        • 1970-01-01
        • 1970-01-01
        • 2011-02-11
        • 2010-10-02
        • 2011-03-22
        • 2012-11-01
        相关资源
        最近更新 更多