Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
|
remoteagentvba [2020/04/26 03:33] 127.0.0.1 external edit |
— (current) | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ===== Remote Agent - VBA ===== | ||
| - | This is an example remote agent in VBA to communicate with // | ||
| - | |||
| - | Below is an example of a VBA agent. This demo is included in the download package. Find the excel file named " | ||
| - | |||
| - | You should see remote commands received from the server in a popup dialog window. When the execution completes, it will display the model execution summary in a popup dialog window. | ||
| - | |||
| - | If you want to run this demo within your own Excel document, MS Access or others, create the following scripts and include TOAgent.vba to the project: | ||
| - | |||
| - | Declare Sub Sleep Lib " | ||
| - | |||
| - | Sub RunTOAgent() | ||
| - | Dim agent As TOAgent | ||
| - | Dim agentID As String | ||
| - | Dim curCmd As String | ||
| - | Dim showNextCmd As String | ||
| - | |||
| - | ' | ||
| - | Set agent = New TOAgent | ||
| - | |||
| - | ' | ||
| - | agent.init " | ||
| - | |||
| - | 'start model execution on TestOptimal server. Params are user id and password. | ||
| - | agent.execModel "", | ||
| - | |||
| - | 'wait 2 seconds to make sure the model execution is started. | ||
| - | Sleep 2000 | ||
| - | |||
| - | ' | ||
| - | agentID = agent.getAgentID() | ||
| - | showNextCmd = vbYes | ||
| - | exitLoop = False | ||
| - | |||
| - | 'loops until no more remote commands received from the server. | ||
| - | Do Until exitLoop | ||
| - | |||
| - | ' | ||
| - | | ||
| - | |||
| - | ' | ||
| - | If (agent.getStatus = " | ||
| - | | ||
| - | Else | ||
| - | ' | ||
| - | ' | ||
| - | If showNextCmd = vbYes Then | ||
| - | | ||
| - | End If | ||
| - | | ||
| - | End If | ||
| - | Loop | ||
| - | |||
| - | 'stop the model execution | ||
| - | agent.stopExec | ||
| - | |||
| - | 'wait for 2 second for the model exeution to stop | ||
| - | Sleep 2000 | ||
| - | |||
| - | 'save the model execution results to be reviewed later with TestOptimal Browser. | ||
| - | agent.saveStat "exec from VBA agent" | ||
| - | |||
| - | MsgBox " | ||
| - | agent.closeModel | ||
| - | End Sub | ||
| - | |||
| - | It ueses " | ||
| - | |||
| - | Since Release 3.0 | ||