FactoryTalk VBA

RobertHart

Member
Join Date
Jun 2016
Location
Alabama
Posts
1
Hey guys. New here and have a vba question for factorytalk.

I'm trying to use vba to pull tag data and then write the data to a textbox and a textfile. I've tried to use the following example that is listed in factorytalk help, but just can't seem to make it work.

Dim WithEvents oGroup As TagGroup
Sub SetUpTagGroup()
On Error Resume Next
Err.Clear
If oGroup Is Nothing Then
Set oGroup = Application.CreateTagGroup(Me.AreaName, 500)
If Err.Number Then
LogDiagnosticsMessage "Error creating TagGroup. Error: " _
& Err.Description, ftDiagSeverityError
Exit Sub
End If
oGroup.Add "System\Second"
oGroup.Add "System\Minute"
oGroup.Active = True
End If
End Sub
Sub SetTagValue()
On Error Resume Next
Dim oTag As Tag
If Not oGroup Is Nothing Then

Set oTag = oGroup.Item("System\Second")
Err.Clear
oTag.Value = 10

' Test the Error number for the result.
Select Case Err.Number

Case 0:
' Write completed successfully... log a message
LogDiagnosticsMessage "Write to tag " & oTag.Name & " was successful."

Case tagErrorReadOnlyAccess:
MsgBox "Unable to write tag value. Client is read-only."

Case tagErrorWriteValue:
If oTag.LastErrorNumber = tagErrorInvalidSecurity Then
MsgBox "Unable to write tag value. The current user does not have security rights."
Else
MsgBox "Error writing tag value. Error: " & _
oTag.LastErrorString
End If

Case tagErrorOperationFailed:
MsgBox "Failed to write to tag. Error: " & Err.Description

End Select
End If

End Sub


I lose it with this piece of code, "Set oGroup = Application.CreateTagGroup(Me.AreaName, 500)".

The name of the textbox is TEXTBOX1. The name of the factorytalk view program is "Production Control System". The name of the sheet is "Laser Short Pour". No matter how I interchange these names with "Application" and "Me", I can not create the group.

I'm sure it is just a lack of understanding on my part so just a little help please.
 
Try:
Code:
Application.CreateTagGroup("/")

I ran into something similar the other day when trying to define the group, ive used this and works with no problems. Keep meaning to get back to look into why it was faulting earlier though.

When you assign the tag to a label, text box, etc... don't forget to ensure they are exposed to vb (Sorry if teaching you to suck eggs).

Ash
 

Similar Topics

I need to use a TreeView in my FactoryTalk SE project and i found it under "ActiveX Object" > "Microsoft TreeView Control 6.0 (SP4)". Everything...
Replies
0
Views
37
I'm creating an HMI that has a recipe with 288 data point. It has 3 pieces of data for 96 segments. I need help with VBA code to copy all 288...
Replies
0
Views
140
Hi everyone Is it possible to change a button image in FactoryTalk View SE (v13.00) using VBA?
Replies
0
Views
82
Hello, I am looking to use the same header on every page (global object) that has an alarm summary button on it that will go to a display with an...
Replies
4
Views
1,808
Back
Top Bottom