Step by Step Guide to Use PE on VBA Applications

download Step by Step Guide to Use PE on VBA Applications

of 11

Transcript of Step by Step Guide to Use PE on VBA Applications

  • 7/23/2019 Step by Step Guide to Use PE on VBA Applications

    1/11

    I. Creating a Trend from in Excel

    1) Open Excel and go to Developer ribbon, click on Visual Basic

    2) Go to Tools / References Menu ad add a reference to Aspen ProcessExplorer 3.0 Object Library

    3) Add a form to the project

  • 7/23/2019 Step by Step Guide to Use PE on VBA Applications

    2/11

    4) On Toolbox windows (it can be open from the View / Toolbox menu), right click on the tab and select New Page

    5) On the New Page, click on any empty space and select Additional Controls

    6) On the Additional control windows select Aspen Trend Plot and Aspentech TimeLine Control

    7) Drag and drop from the Trend Icon to the Windows Form

  • 7/23/2019 Step by Step Guide to Use PE on VBA Applications

    3/11

    8) Expand the new object to the desired size

    9) Repeat step 7 and 8 using the TimeLine control; put this control below the Trend control on the form

  • 7/23/2019 Step by Step Guide to Use PE on VBA Applications

    4/11

    10) Click on Play button, you should have a Form in Excel which have the same basic functionality as a Process Explorer

    trend

  • 7/23/2019 Step by Step Guide to Use PE on VBA Applications

    5/11

    II. Adding a tag programmatically

    1) Starting from the previous example, drag and drop a CommandButton to the windows form, use the Caption option

    on the properties box for the button to change the text on it:

    2) Double click on the button in the form to generate the OnClick event code

    3) Copy the code below between previous two lines:

    Dim Tag, Map, Server

    Tag = "ATCAI" 'Change this for a your tag name

    Map = "IP_AnalogMap" 'Change this for your mapping record

    Server = "" 'Change this for a dataspurce name

    TrendPlot1.TrendTags.Add Server, Map, Tag

  • 7/23/2019 Step by Step Guide to Use PE on VBA Applications

    6/11

    4) Click on Play, the form will start running. By clicking on Add Tag button, it will add the tag name on code

    automatically:

  • 7/23/2019 Step by Step Guide to Use PE on VBA Applications

    7/11

    III. Adding a Scooter programmatically

    1) Starting from previous example, go to Tools / References Menu and add a reference to Aspen Trend Chart Library. If

    cannot find the reference on the list, browse it to the folder C:\Program Files (x86)\Common Files\AspenTech

    Shared\Apex and select TrendChart.ocx

    2) Follow steps 1 to 2 to add another button to add a new scooter, change caption of the button to Add scooter:

    3) Copy this code between the lines of the second button click event

    Dim MyScooters As AtTrendCharts.Scooters

    Set MyScooters = TrendPlot1.Scooters

    Dim time As Date

    time = Now - (1 / 24 / 6) 'now minus 10 minutes

    MyScooters.Add time

  • 7/23/2019 Step by Step Guide to Use PE on VBA Applications

    8/11

    3) Click on Play, the form will start running. By clicking on Add Scooter button, it will add the scotter 10 minutes before

    current time automatically:

  • 7/23/2019 Step by Step Guide to Use PE on VBA Applications

    9/11

    IV. Calling the Form from Excel

    1) Save the project from Excel Save menu

    2) Close it an open it again.

    3) Go to Developer tag, click on Insert and select Button (Form Control)

  • 7/23/2019 Step by Step Guide to Use PE on VBA Applications

    10/11

    4) Draw the button on the Excel spreadsheet, after drawing the button a windows calling a Macro for this button will be

    displayed, click on New

    (if you close this windows by error, it can be called again by right click over the button and select Assign Macro)

    5) On the code screen, copy this code between the Button 1 Click event code:

    UserForm1.Show

  • 7/23/2019 Step by Step Guide to Use PE on VBA Applications

    11/11

    6) Save the project and run it. Close the From open. Now by clicking over the Button in the Spreadsheet the form will be

    displayed.