Showing results 1 to 2 of 2

Thread: Event in „Dachprojekt“ on alarm occurrence in an underlying project

  1. #1
    Join Date
    29.07.2007
    Location
    Germany
    Posts
    192

    Default Event in „Dachprojekt“ on alarm occurrence in an underlying project

    Hello everybody!

    Is there a way to get a VBA event in the “Dachprojekt” in case of alarm occurrence in one of the projects under the “Dachprojekt”.
    Sample out of the help:

    Dim WithEvents zAlarm As Alarm
    
    'procedure is executed on startup of the zenOn runtime
    Private Sub Project_Active()
        'init the alarm object for events
        Set zAlarm = thisProject.Alarm
    End Sub
    
    'procedure is executed when an Alarm comes
    Private Sub zAlarm_AlarmComes(ByVal obItem As IAlarmItem)
        'print specific information to Debug window...
        Debug.Print obItem.Timecomes & " > " & obItem.Text
    End Sub
    
    'procedure is executed on terminating the zenOn Runtime
    Private Sub Project_Inactive()
        'free the alarm object
        Set zAlarm = Nothing
    End Sub

    The sample is only working for alarms of variable located in the “Dachprojekt” no event is created for alarms in the projects under the “Dachprojekt”
    We need to know in the “Dachprojekt” information of the underlying projects:
    What alarms are active, are they acknowledged. Event based reacting on this information in VBA of the Dachprojekt is needed.

    The underlying projects can’t be changed since they are not in our hands we have to use them as they are.

    Thanks for any input!

    By the way "Dachprojekt" in english?

    Regards,

    H.-P.

  2. #2
    robertf Gast

    Default Re: Event in „Dachprojekt“ on alarm occurrence in an underlying project

    Hello hp!

    "Dachprojekt" means the project on the top of the project hierarchy. In English you may call it RoofProject...

    Here is a small Sample how to get the Alarm Events from SUB Projects:

    Dim WithEvents obALARM As Alarm
    Dim WithEvents obSubPrj As Project
    
    Private Sub obALARM_AlarmAcknowledged(ByVal obItem As IAlarmItem)
        Debug.Print "* " & obItem.Text & "  >> " & obItem.Projectname
    End Sub
    
    Private Sub obALARM_AlarmComes(ByVal obItem As IAlarmItem)
        Debug.Print "+ " & obItem.Text & "  >> " & obItem.Projectname
    End Sub
    
    Private Sub obALARM_AlarmGoes(ByVal obItem As IAlarmItem)
        Debug.Print "- " & obItem.Text & "  >> " & obItem.Projectname
    End Sub
    
    Private Sub obSubPrj_Inactive()
        Debug.Print "SUB Project is not longer available"
        'alarm events of this project are not fired until it is reinitialized
    End Sub
    
    Private Sub Project_Active()
        Set obSubPrj = Application.Projects.Item("SUB1")
        If Not obSubPrj Is Nothing Then
            Set obALARM = obSubPrj.Alarm
        End If
    End Sub
    
    Private Sub Project_Inactive()
        Set obALARM = Nothing
        Set obSubPrj = Nothing
    End Sub

    I hope it helps

Similar Threads

  1. The event OnElementCreated is not executed
    By markclemens in forum VBA
    Replies: 0
    Last Post: 21st February 2008, 14:31
  2. Replies: 3
    Last Post: 7th February 2008, 16:55

Posting Rules

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