First, in the always open / updating window, make global tags for:
Dim HMIGlobalGroup As TagGroup
Dim HMIGlobalTag As Tag
Dim TagsInError As StringList
Dim Results As Boolean
Now initialize the Global Group:
(animation_start is a good place for this initialization)
Set HMIGlobalGroup = Application.CreateTagGroup(Me.AreaName, 50)
Once created, you can add tags to it:
HMIGlobalGroup.Add("[My_Data_Server]My_First_Tag")
HMIGlobalGroup.Add("[My_PLC]My_Timer.ACC")
--------------------------
Once some tags are added, (provided HMIGlobalGroup is globally scoped) you can access the tags in it from any VBA function for that display...
To set a tag to a value is a multi-step process...
Set the Global tag to the item from the group:
'Set Tag to item:
HMIGlobalTag = HMIGlobalGroup.Item("[My_Data_Server]My_First_Tag")
'Set the new value for the tag:
HMIGlobalTag.PendingWriteValue = 25.3
'Commit the write
Results = HMIGlobalGroup.WritePendingValues(TagsInError)
----- Advantage that way, is you can actually set multiple tags to be written at once, then commit them all.
To read values from tags in the group, use the value property:
Set HMIGlobalTag = HMIGlobalGroup.Item("[My_PLC]My_Timer.ACC")
Dim Current_ACC as INT
Current_ACC = HMIGlobalTag.Value
Bit of a PITA, but it works.