Showing results 1 to 6 of 6

Thread: VBA Wizard don't work properly with multiple Element of Type 130

  1. #1

    Default VBA Wizard don't work properly with multiple Element of Type 130

    Hello support!

    We want to change some values inside the Dynproperties of some elements of type 130 (i.e the $_xxxx propetries). To do this we have followed the example of the COPA DATA Wizard 'frmSymbol'.
    We apply the procedure to many (i.e. more than one) obElements of the current Picture and when we try to get the value of the Dynproperties they are equal to zero. The only valid values that we get belong to the element that have the focus on page.
    In other words only one of the obElement that we query for Dynpropertie's values that answers correctly is the only that have the focus.
    Our procedure is the following: we call the frmSymbol at the Doubleclick on page and getting the parent picture we apply the frmSymbol's code for all the obElerments of the page that are of Type 130; unfortunately we have valid values for the Dynproperties (i.e. non equal to zero) only for the obElement we have select with the doubleclick.
    The values of the standard properties of all the obElements are read correctly but the dynproperties instead no (only for the selected one)!?!?!?

    The questions are:
    1. Is it a limit of the VBA interface?
    2. What we have do wrong ?
    3. There is a workaround?

    Let me know.
    Thank you in advance.
    Best regards.

  2. #2

    Default Re: VBA Wizard don't work properly with multiple Element of Type 130

    Hi,

    No, this is not a general limitation of the VBA interface. You can get all the released properties of all symbols (elements of the type 130) in a screen.

    What you have done wrong is hard to tell with just the description, however my guess is that this is an issue in your VBA code, in the way how you go through all the elements in the screen and determine whether this is a symbol or not.

    Below is a sample that uses a part of the frmSymbol example to get the released properties for all elements of the type 130 in the screen "a".

    Sub get_sym_param()
    Dim myPic As DynPicture
    Dim myElem As Element
    Dim vProps() As Variant
    Dim v As Variant
    Dim Result() As String
    Dim syms As Integer
    Dim k As Integer
    Dim i As Integer
    Dim n As Integer
    Dim Pos As Integer
    Dim s As String
    
    Set myPic = MyWorkspace.ActiveDocument.DynPictures.Item("a")
    syms = 0
    If Not myPic Is Nothing Then
    
        For k = 0 To myPic.Elements.Count - 1
        Set myElem = myPic.Elements.Item(k)
        If Not myElem Is Nothing Then
            If myElem.Type = 130 Then
                ReDim Preserve vProps(syms)
                v = myElem.DynPropertiesEnum("")
                ReDim Result(3, 0)
                n = 0
                For i = 0 To UBound(v)
                    s = v(i)
                    s = Mid(s, 1, InStr(1, s, ",") - 1)
                    If InStr(1, s, "\") <> 0 Then
                        Result(0, n) = Mid(s, 1, InStr(1, s, "\") - 1)
                        Result(1, n) = Mid(s, InStr(1, s, "\") + 1)
                        Pos = InStr(1, v(i), ",") + 1
                        Result(2, n) = Mid(v(i), Pos, InStr(Pos, v(i), ",") - Pos)
                        Pos = InStr(Pos, v(i), ",") + 1
                        Result(3, n) = Mid(v(i), Pos)
                        n = n + 1
                        ReDim Preserve Result(3, n)
                    End If
                Next i
                vProps(syms) = Result
            syms = syms + 1
            End If
        End If
        Next k
    End If
    End Sub

  3. #3
    grrm Gast

    Default Re: VBA Wizard don't work properly with multiple Element of Type 130

    Unfortunately don't works.
    Please consider the code below that you can test quickly:

    ----------------------------------------------------------------------------------------

    Private Sub ZenWorkspace_OnElementDoubleClicked(ByVal obElement As Element)

    Dim ObPicture As DynPicture
    Dim i As Integer

    Set ObPicture = obElement.Parent.Parent
    For i = 0 To ObPicture.Elements.Count - 1

    Set obElement = ObPicture.Elements.Item(i)
    DoEvents

    If Not obElement Is Nothing Then

    If obElement.Type = 130 Then
    'symbol...
    If SymbolHasProps(obElement) = True Then
    'start wizard...
    frmSymbol.InitWizard obElement
    frmSymbol.Show
    End If
    End If

    End If

    Next

    End Sub
    ----------------------------------------------------------------------------------------

    Just double clicking over an element then the frmSysmbol is started for all the elements in
    the Picture in sequence. Then if you try to display the value of $_xxxx fields they are all equal to zero for all the elements in the picture. The value are correctly shown only for the element you have double clicked on !?!?!?

    Please check and let me know your results...
    Thank you in advance.
    Best regards

  4. #4
    grrm Gast

    Default Re: VBA Wizard don't work properly with multiple Element of Type 130

    Hi.
    I Have changed the code a little bit as below:

    ------------------------------------------------------------------------------

    Private Sub ZenWorkspace_OnElementDoubleClicked(ByVal obInputElement As Element)

    Dim ObPicture As DynPicture
    Dim i As Integer
    Dim obElement As Element


    Set ObPicture = obInputElement.Parent.Parent
    For i = 0 To ObPicture.Elements.Count - 1

    Set obElement = ObPicture.Elements.Item(i)
    DoEvents
    .....

    ----------------------------------------------------

    I have just defined locally the obElement then different form the one passed to the sub (i.e. obInputElement).
    Unfortunately still don't works!

    Best regards

  5. #5
    Join Date
    29.07.2007
    Posts
    5

    Default Re: VBA Wizard don't work properly with multiple Element of Type 130

    It seems a problem related with Object selection in Editor.
    Check this sample code:

    Public Sub test()
        
        Dim myElement As Element
        Dim myPic As DynPicture
        Dim i As Integer
          
        Set myPic = MyWorkspace.ActiveDocument.DynPictures.Item("Screen 0")
        [COLOR="Blue"]'Set myPic = thisProject.DynPictures.Item("Screen 0")[/COLOR]
        
    
        For i = 0 To myPic.Elements.Count - 1
            Set myElement = myPic.Elements.Item(i)
        '        frmSymbol.InitWizard obElement
        '        frmSymbol.Show
            If myElement.Type = 130 Then
                MsgBox "Object Name:" & myElement.name & vbCrLf & "Color: " & CStr(myElement.DynProperties("$_Element_1\BackColor"))
            End If
            Set myElement = Nothing
            
        Next i
        
        
        
        Set myPic = Nothing
        Set myElement = Nothing
    End Sub

    if we have many Symbols in the Page "Screen 0", with a Sub-Element called "Element_1", and if we publish the BackColor property, this macro will display the color number of all Symbols sub-elements ONLY if no symbols is selected in the Page.
    If we select one Symbol, the macro will only display the BackColor code of the sub-element of the selected Symbol.
    The others Backcolor codes are returned with value '0'.

  6. #6
    grrm Gast

    Default Re: VBA Wizard don't work properly with multiple Element of Type 130

    Hello Support

    Good news!!!

    In our case we deal only with elements of Type 130 and we read/write only Dynproperties.

    Following the indication of 'matteo' above we found out that our procedure
    works properly if the element still selected in the picture is of Type different from 130!!

    Then for us the workaround is simple: just peek the information from the page doublecliking everywhere but then start the procedure only after doubleclicking over an
    an element of type different from Type 130. In this way we can manage correctly all the
    Dynproperties of all the Symbol elements in the current page!!!

    For us the thread is closed successfully.
    Thank you very much to all.
    Best regards
    Massimiliano Guerra

Similar Threads

  1. VBA Wizard Zuordnungen
    By perschke in forum VBA
    Replies: 1
    Last Post: 14th July 2011, 12:32
  2. Replies: 0
    Last Post: 25th September 2007, 14:10
  3. Processor type
    By sebastiank in forum zenon Operator
    Replies: 0
    Last Post: 19th September 2007, 16:15
  4. more than one driver of same type
    By sebastiank in forum zenon Operator
    Replies: 0
    Last Post: 18th September 2007, 07:36
  5. Replies: 0
    Last Post: 20th August 2007, 13:08

Posting Rules

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •