Showing results 1 to 5 of 5

Thread: VBA on the client

  1. #1

    Default VBA on the client

    Hello!

    I have the project with 2 PCs: the first with Editor and Runtime as server, the second only with Runtime. So the same project runs both on the 1 and on the 2 PC.

    I have created mouse over VBA, that contains simple code:

    Public Sub MouseOver_EO_WO2_KM1(obElem As Element, vPosX As Variant, vPosY As Variant)
    If thisProject.Variables.Item("BacnetIP.Sch_31.KM11").Value = 1 Then
    thisProject.RtFunctions.Item("f_set_WO3adm_KM11_0").Start
    End If
    End Sub


    On the 1 PC the VBA macro works properly, but on the second I`ve got the error message:

    Run-time error 13. Type mismatch.

    What does it mean? And what should I do to work macro MouseOver on the second PC?

    Regards.

  2. #2

    Default Re: VBA on the client

    Hi,

    One thing I notice immediately here is, that you access the .Value property, without checking first if it is has a valid value.

    Before you can read certain variable properties, it must be ascertained that .IsOnline returns TRUE, basically that the variable has a valid value.

    Do a search of the forum for ".IsOnline" for further information on advise, online container and DDE active.

    Also you use a variable object, without checking if it exists with that name in the project. (Normally it should when it works on the server, but it is never a bad idea to add some basic error checking so that your code does not produce such errors when e.g. the variable is renamed)


    Public Sub MouseOver_EO_WO2_KM1(obElem As Element, vPosX As Variant, vPosY As Variant)
    Dim obVar As Variable
    Set obVar = thisProject.Variables.Item("BacnetIP.Sch_31.KM11")
    'check, does the variable exist
    If (Not obVar Is Nothing) Then
        'check can the .Value property be read (does the variable have a valid value)
        If obVar.IsOnline Then
            If thisProject.Variables.Item("BacnetIP.Sch_31.KM11").Value = 1 Then
                thisProject.RtFunctions.Item("f_set_WO3adm_KM11_0").Start
            End If
        End If
    End If
    End Sub

    Best regards,
    Mark

  3. #3

    Default Re: VBA on the client

    I have sighted, that the problem occurs during the accessing to the variable: thisProject.Variables.Item("BacnetIP.Sch_31.KM11") .Value = 1.
    When I commented this line - the macro begun to work both on the 1 and on the 2 PC.
    The problem is that I need this condition. How can I use the accessing to the variable on the client as on the server?

  4. #4

    Default Re: VBA on the client

    Thank you, Mark

  5. #5

    Default Re: VBA on the client

    Hi croc,

    Have a look in the release notes at the chapter "All versions - VBA: Direct variable access via request no longer possible" where this topic is described in more detail.

    Basically, when you implement the suggested code, and at the variable used in the macro set the option "DDE active", it should also work on the client.

    Best regards,
    Mar

Similar Threads

  1. Web client VBA
    By jurijcadez in forum VBA
    Replies: 3
    Last Post: 15th May 2012, 14:43
  2. Mathevariable am Client
    By brenner in forum zenon Supervisor
    Replies: 1
    Last Post: 11th June 2010, 18:53
  3. Client having 2 monitors
    By shikra in forum zenon Supervisor
    Replies: 1
    Last Post: 12th May 2010, 19:21
  4. Client license
    By janlyndon in forum zenon Operator
    Replies: 2
    Last Post: 12th May 2010, 12:54
  5. Menus in the Client
    By shikra in forum zenon Supervisor
    Replies: 3
    Last Post: 10th May 2010, 10:04

Posting Rules

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