Link VBA with Straton WB by using StratOnCom interface
Link VBA with straton WB by using StratOnCom interface
This topic describes how to configure the VBA editor
to connect with the Straton Workbench and how to use the StratOnCom interface. First of all you need a Straton Workbench Project. Create one.
Open the VBA Editor and select “myWorkspace” and click on the meneu “Extras/References” and set the “StratOnCom” active.
Now you can use the Straton Com Interface for your VBA Project
This code sample shows us how to initialize the com interface for your project:
Attention! The VBA access to the straton workbench just works in the zenon workpace (zenon Editor)!
Public Sub
StratonTest()
‘Create a new instanz on the SratOnCom Object
Dim myStraton As New StratOnCom.Project
Dim myPath As String
‘Path to the Straton Path
myPath = “C:\ProgramData\COPA-DATA\SQL\ff8cdbaa-47f3-44e8-bd33-1c582fd4cadc\FILES\straton\Project”
‘Set the entry point to your straton project
myStraton.ProjectPath = myPath
‘Show straton path again
Debug.Print myStraton.ProjectPath
‘Count all my Straton Programs
Debug.Print myStraton.Programs.Count
‘Show the name of the first program
Debug.Print myStraton.Programs.Item(0).Name
‘Show the first global Variable
Debug.Print myStraton.GlobalVariables.Item(0).Name
‘Show some details of the first retain variable
Debug.Print myStraton.RetainVariables.Item(0).Name
Debug.Print myStraton.RetainVariables.Item(0).Comment
Debug.Print myStraton.RetainVariables.Item(0).EmbedSymbol
Debug.Print myStraton.RetainVariables.Item(0).InitValue
Debug.Print myStraton.RetainVariables.Item(0).Tag
End Sub
The following list shows the objects available
for both VBA and VSTA.
– StratonCom
– Project
– GlobalVariables
– Variables
– Variable
– VarProps
– VarProperty
– RetainVariables
– Variables
– Variable
– VarProps
– VarProperty
– Programs
– Variables
– Variable
– VarProps
– VarProperty
– ProgramContent
– ProgramObjects
– GraphicalObject
– ProgramLines
– LineObject
Tags: Programming, straton & zenon Logic