Automation in code generation: Lesson 4 – Scanning specific objects in a location.

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


Print Friendly, PDF & Email

Este artigo foi útil? Was this helpful?

Classificação média - Average rating 0 / 5. Count: 0

Leave a Reply

Your email address will not be published.Required fields are marked *