Showing results 1 to 4 of 4

Thread: How To Access Project Variables

  1. #1
    Join Date
    23.04.2015
    Posts
    2

    Default How To Access Project Variables

    Hello, I'm new in Copadata SCADA and I'm trying to edit Zenon7.0 Supervisor project and I'm trying to use VBA macro in a Function (in that way I'm working with successfull with other SCADA systems). Where is my mistake in this vba macro:

    Public Sub OPEN_FILE_EXCEL()
    Dim objExcelApp
    Set objExcelApp = CreateObject("Excel.Application")
    objExcelApp.Visible = 1
    objExcelApp.Workbooks.Open "D:\PROBA\PROBA.xlsx"
    objExcelApp.Cells(1, 2).Value = "proba zenon"
    objExcelApp.Cells(1, 3).Value = thisProject.Variables.Item("PLC1.PROGRAM1.VARIABLE_NAME1").Value
    objExcelApp.ActiveWorkbook.Save
    objExcelApp.Workbooks.Close
    objExcelApp.Quit
    End Sub

    This script is working fine without the row "....Cels(1,3) = ...." I may have a mistake in a way to access variable value from variables of the project. How to access that variables?

    or in this script:

    Public Sub TRANSFER_DAILY_FACTORY_VALUES()
    thisProject.Variables.Item("VARIABLE_NAME_Driver_for_INTERNAL_1").Value = thisProject.Variables.Item("PLC1..GLOBAL_VARIABLES.VARIABLE_NAME_2_from_CoDeSy s_OPC_DA_driver").Value
    End Sub

    Thank You in Аdvance

  2. #2
    Join Date
    30.05.2007
    Location
    Salzburg
    Posts
    881

    Default Re: How To Access Project Variables

    why not using the built-in zenon function "Export data"?
    -> see help documentation at Manual -> Variables -> Functions for variables -> Export data

    doing so you
    - don't need a licensed Excel installed on that pc (zenon Runtime) where you want to export the data
    - don't need to do any coding (VBA, VSTA,... ) in zenon

    also if historical data from the zenon archive server is needed in text files there exists a similar function
    -> see Manual -> Historian -> Functions -> Export archive

    to open the online help documentation you can i.e. simply hit function key F1 in the zenon Editor.

    regards,
    herbert


  3. #3
    Join Date
    23.04.2015
    Posts
    2

    Default Re: How To Access Project Variables

    Thank You for the answer.

    Yes, I saw this , but the requirements of the client is another format of data in a tables.

    Can You make an example how to access project variables in a vba macro?

    I suppose that I'm a little wrong in format. This is a very simple task in another SCADA systems, that I have used before.

  4. #4
    Join Date
    30.05.2007
    Location
    Salzburg
    Posts
    881

    Default Re: How To Access Project Variables

    If you are looking for reporting functions following zenon modules will help you (again, no need of doing this programmatically via VBA, ... ):
    Manual -> Reporting -> Report Viewer
    Manual -> Reporting -> Report Generator


    Using "Report Viewer" you will have the possibility to have nice designed reports
    -> see a short demonstration here: https://www.youtube.com/watch?v=oDNXz-5nFAI

    regards,
    herbert


Similar Threads

  1. Replies: 1
    Last Post: 26th February 2015, 10:56
  2. Replies: 1
    Last Post: 24th June 2014, 19:51
  3. Replies: 2
    Last Post: 8th April 2013, 00:28
  4. Replies: 7
    Last Post: 8th May 2012, 10:46
  5. Program access to structure datatype variables
    By stolyarov_as in forum VBA
    Replies: 2
    Last Post: 8th August 2011, 14:21

Posting Rules

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