FactoryTalk View SE VBA Tags to Excel

kota_rt

Member
Join Date
Jan 2005
Location
Saginaw, Michigan
Posts
11
I'm looking for a better solution to place the values of 100 SLC N7 tags on an excel spreadsheet from a FactoryTalk View SE display VBA Subroutine. I can create a tag group in vba, add all the tag names to the group, get the values and write them to the excel spreadsheet. But there has got to be an easier way that I'm overlooking! In excel I can use a DDE Request and automate the process easily, but I really need to have FT View do the "driving" in this case. Does anyone have a better way to do this?
 
I think what you want to do is have FTView write the tags directly to the Excel sheet. Are these values going to constantly overwrite the same cells or do you need to create a simple database of values? You need to expose the Excel object model in FTView VBA editor. Then you will have the Excel command to create a sheet and populate it with values. Excel will need to be installed on the FTView server to get the object model.
 
That is the correct procedure for FTViews VBA.

You aren't creating the tag group every time though, are you? For code like that, I just put it in a hidden window, and create all the tag groups once on initialization, and then just refresh them prior to working with them.


I suppose, it might be 'easier', using SLC Files, to build up each tagname in a loop to add them to the collection.
 
Dear All;I'M Currently Using Factory Talk View SE (V6.1) SCADA. I Want to have Current Values of Tags (Process Parameters) to belogged in Excel Sheet by Every two Hr.s I'm Trying to write VBA Code to open Excel Sheet & Write the Values in This Excel Sheet & Close it Again. At next Day morning This Sheet will be saved by a name of the date.Can any body guide me for this.. Thanks!!!!!
 
Hi ghatevinod

You Can try Below Script with some modification such as save file path and tags.



Private Sub NumericInput5_Change()
Dim sFileName As String, sPath As String
If MyTagGroup Is Nothing Then
Set MyTagGroup = Application.CreateTagGroup(Me.AreaName)
MyTagGroup.Add "AI\I1"
MyTagGroup.Add "AI\I2"
MyTagGroup.Add "AI\I3"
MyTagGroup.Add "AI\I4"

' On Error GoTo ErrorHandler
Dim SourceErrFile, DestErrFile
Dim Tag1 As Tag
Dim Tag2 As Tag
Dim Tag3 As Tag
Dim Tag4 As Tag

Dim Mytime
'Set the tag objects
Set Tag1 = MyTagGroup.Item("AI\I1")
Set Tag2 = MyTagGroup.Item("AI\I2")
Set Tag3 = MyTagGroup.Item("AI\I3")
Set Tag4 = MyTagGroup.Item("AI\I4")


Excel.Application.Workbooks.Open "C:\resourcelibrary\import.csv"
Excel.Application.Visible = True

Cells(2, 4) = Tag1.Value
Cells(3, 4) = Tag2.Value
Cells(4, 4) = Tag3.Value
Cells(5, 4) = Tag4.Value
ChDir "C:\resourcelibrary"


ActiveWorkbook.SaveAs Filename:="C:\resourcelibrary\Import" & "-" & Format(Now, "dd-mmm-yyyy-hh-mm-ss") & ".xls"


Filename:="C:\resourcelibrary\Import.xls" & Date & " " & Time


ActiveWorkbook.Close



End If
End Sub
 
Dear Bansodevb Thanks for the help....I have Some Query. What is me.AreaName, as our SCADA is Factory Talkview SE So whether it should be se.AreaName?Whether I shoul Write AI/I1 As AI/PT_111Our Tags Has not been Defined in SCADA System But He is Importing From Server Excel.Application.Workbooks.Open "C:\resourcelibrary\import.csv"In this whether I have to give the Path for Excel Application to Open? Like "c:\Programme file\microsoftoffice\office12\excel.exe" ??Also If you would like to share your Mail ID & Phone No. so that I can be in touch with You... Thanks Once againGhate [email protected]
 
Are you browsing PLC tags directly in SE?

me.AreaName This is Script Syntax don't change it.
me is not ME(Machine Edition).

C:\resourcelibrary\import.csv this is Path of the .CSV file where tag values will be store.
 
Yes Tags are browse directly. They are not defined in SCADA. So does this path is valid for Import.csv is required in this case also.
Thanks!!!!!
 
Dear Bansodevb,

me.AreaName is Script Syntax. But it is showing error at 'me' while trying to run script as 'invalid use of Me keyword'. what to write in place of me?? else say any solution for it..
 
Dear Bansodevb,

me.AreaName is Script Syntax. But it is showing error at 'me' while trying to run script as 'invalid use of Me keyword'. what to write in place of me?? else say any solution for it..


Where are you using this script?

This script is for FT View SE (VBA).
 
Dear Sir,
I am using this in FTVIEW SE (VBA) only. But m nt getting y it is showing the error.
It keep saying 'invalid use of ME keyword'. I need to define Me??
 

Similar Topics

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
123
Hi, Can someone guide me through how to use FactoryTalk SE VB script to open communication with SQL Server? which command I can use? Are there...
Replies
2
Views
2,249
Hello group, I have been migrating a project from RSView 32 V7.6 to FactoryTalk View SE Local Station V12 over the last couple of days. All told...
Replies
0
Views
991
For trend charts, I can use an ActiveX Calendar control to select a date on a trend using the following code where "Trend" is the name of the...
Replies
2
Views
1,561
Anyone know how to change the mouse icon to something else using VBA? It looks like it can be done with VBA forms and based on the object the...
Replies
0
Views
2,201
Back
Top Bottom