كيف يمكنني استرجاع برنامج Visio المعلومات شكل مخصص مع VBA

StackOverflow https://stackoverflow.com/questions/507409

سؤال

<ع> استخدام VBA، كيف يمكنني استرجاع مخصص تشكيل المعلومات من مخطط Visio 2003.

هل كانت مفيدة؟

المحلول

لتحصل مخصصة تشكيل المعلومات من شكل Visio:

Function GetCustomPropertyValue(TheShape As Visio.Shape, ThePropertyName As String) As String
    On Error Resume Next
    GetCustomPropertyValue = TheShape.CellsU("Prop." & ThePropertyName).ResultStr(visNone)
End Function
يستخدم

وجميع هذه الوظيفة لا هي ملك cellsu على شكل للحصول على خلية رقة خاصية مخصصة بالاسم ...

إذا كنت المتمسك حول استخدام على استئناف خطأ المقبل، يمكن أن تحقق لمعرفة ما إذا كان يوجد الخلية عن طريق فحص أولا في حالة وجود الخلية:

if TheShape.CellExistsU( "Prop." & ThePropertyName , 0 ) then
GetCustomPropertyValue = TheShape.CellsU("Prop." & THePropertyName).ResultStr(VisNone)

نصائح أخرى

وجدت هذا في http://visio.mvps.org/VBA.htm (خصائص مخصصة)

Public Sub CustomProp()
    Dim shpObj As Visio.Shape, celObj As Visio.Cell
    Dim i As Integer, j As Integer, ShpNo As Integer
    Dim LabelName As String, PromptName As String, ValName As String, Tabchr As String

    Open "C:\CustomProp.txt" For Output Shared As #1

    Tabchr = Chr(9)

    For ShpNo = 1 To Visio.ActivePage.Shapes.Count
        Set shpObj = Visio.ActivePage.Shapes(ShpNo)
        nRows = shpObj.RowCount(Visio.visSectionProp)
        For i = 0 To nRows - 1
            Set celObj = shpObj.CellsSRC(Visio.visSectionProp, i, 0)
            ValName = celObj.ResultStr(Visio.visNone)
            Set celObj = shpObj.CellsSRC(Visio.visSectionProp, i, 1)
            PromptName = celObj.ResultStr(Visio.visNone)
            Set celObj = shpObj.CellsSRC(Visio.visSectionProp, i, 2)
            LabelName = celObj.ResultStr(Visio.visNone)

            Debug.Print shpObj.Name, LabelName, PromptName, ValName
            Print #1, shpObj.Name; Tabchr; LabelName; Tabchr; PromptName; Tabchr; ValName
        Next i
    Next ShpNo

    Close #1
End Sub
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top