Showing results 1 to 8 of 8

Thread: Create an Element

  1. #1
    robertf Gast

    Default Create an Element

    Here is a sample how to create a textbutton with vba...

    '##########################################################
    '## A Procedure to create a new textbutton in a picture. ##
    '## Several properties will be set and a function linked ##
    '##########################################################
    Sub CreateElement()
        Dim zPIC As DynPicture
        Dim zELE As Element
        Const strPicture As String = "PictureName"
        Const strElement As String = "ElementName"
        Const strFunction As String = "FunctionName"
        'get Picture object
        Set zPIC = MyWorkspace.ActiveDocument.DynPictures.Item(strPicture)
        'if picture object is nothing, the picture doesn't exist...
        If zPIC Is Nothing Then Exit Sub
        'get Element object
        Set zELE = zPIC.Elements.Item(strElement)
        'if element object is nothing, a new one can be created...
        If zELE Is Nothing Then
            'create a new element (Text-Button)
            Set zELE = zPIC.Elements.Create(strElement, tpDynButton)
            'set properties of the new element
            With zELE
            'set size and position
            .Left = 100
            .Top = 100
            .Width = 150
            .Height = 50
            'set graphic representation
            .BackColor = vbBlue
            .ForeColor = vbWhite
            .DynProperties("BtnStyle3D") = True
            .DynProperties("BtnStyleFill") = 2
            .DynProperties("BtnStyleBorder") = 0
            .DynProperties("Text1") = "New TextButton"
            .DynProperties("Text2") = "(created by VBA)"
            'link a function
            .DynProperties("Function") = strFunction
            End With
        End If
    End Sub

  2. #2
    Join Date
    05.03.2012
    Posts
    1

    Default Re: Create an Element

    hi
    is possible copy element? i do not find methode for copy

  3. #3

    Default Re: Create an Element

    Hi,

    Welcome to the forum!
    Copying an element in the programming interface is not possible.

    What is it exactly that you would like to do?

    Regards,
    Mark

  4. #4
    Join Date
    21.05.2014
    Posts
    32

    Default Re: Create an Element

    hi,

    I copied this sample code into a VBA editor and did the appropriate name changes to create an element in a screen. When I execute ZenOn, I get an error showing that object is not defined. I found while debugging that my element still shows "nothing" even after create command. It shows error in the next line (Left = 100). Can you please tell, where did I went wrong.

    Thanks!
    Jyo

  5. #5
    Join Date
    21.05.2014
    Posts
    32

    Default Re: Create an Element

    Hello,

    Sorry for the repeated question. I guess, someone before have raised the same case. Now, I would like to modify the question. What is the difference between creating an element in the ZenOn runtime (Which can't be done, as I read here) and ZenOn Editor using VBA
    Thank you!
    Jyo

  6. #6
    Join Date
    20.08.2009
    Posts
    293

    Default AW: Create an Element

    Hi,

    what exactly do you want to do?

    The fact why elements cannot be created in the Runtime has conceptual reasons and this also won't be changed in the future.

    For element dynamics in the runtime you have visibility, flashing, rotation, movement, etc.

    Regards,
    Bernhard

  7. #7
    Join Date
    21.05.2014
    Posts
    32

    Default Re: Create an Element

    Hello Bernhard,
    Thanks for your reply. I just saw this code and wanted to try (expecting it to create in runtime). Later, I came to know it is not for Runtime. But, Could you please expalin me, why this particular creation of element via VBA is used. Is it anything different from creating in ZenOn itself.
    Regards

  8. #8
    Join Date
    20.08.2009
    Posts
    293

    Default AW: Create an Element

    Hi,

    it is used for automatic creation of elements (e.g. in a wizard).

    For example you want to have a "standardized" template project, you can write some code that creates the project.

    Of course this does not always make sense.

    Regards,
    Bernhard

Posting Rules

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