Another possibility is to use the technique of scanning a certain location (such as a data folder or a substation) to look for specific types of objects (internal tags, switchers, etc.). This can be done via for each instruction and TypeName method. An example:
'points to the location to be scanned set folder = Application.GetObject("Data") 'for each object in the location for each obj in folder 'if it is the desired type If TypeName(obj) = "InternalTag" then MsgBox obj.Name End If next
You can replace MsgBox with the action you wish to perform in the object.
If you wish to scan all data objects from the application, you must point the location to an object’s Application property. For example:
'points to the place to be scanned
set folder = Application.GetObject("Data").Application
Before proceeding to Lesson 5, we recommend reading the following articles:
KB-31936: Function returning the object type.
Accesing all tags of a Driver.
Related articles
- Automation in code generation: Introduction.
- Automation in code generation: Lesson 1 – Working with vectors.
- Automation in code generation: Lesson 2 – Reading information from an Excel file.
- Automation in code generation: Lesson 3 – Changing a string into a vector.
- Automation in code generation: Lesson 4 – Scanning specific objects in a location.
- Automation in code generation: Lesson 5 – Adding objects via scripts.
- Automation in code generation: Lesson 6 – Checking for pre-existing objects.
- Automation in code generation: Lesson 7 – Events for script execution.