FTView SE/Vba and MS Excel

anthony.h

Member
Join Date
Mar 2011
Location
Inside a PLC
Posts
1
Hello All, I currently have installed a Compact Logix L35E and Factory Talk View SE on a Scada PC. Question I have is regarding FTView SE and Vba with Excel. I have some VB.net experience but not much. I need to append four different analogue measurements to a excel spreadsheet every 15 minutes. I have searched the web and found vba snippets and have the following code below working ok. On a button press, excel will open, write the tag values to the specific cells, save and close. this is fine, but I need to increment or point to the next empty cell when writing the next set of tags. I can not keep over writing the current cells like I currently am, Does anyone have any vba code or clues as to do this?
Thanks Anthony



Private Sub Button4_Released()

Dim ObjExcelApp As Object
Dim Fname As String

Set MyTagGroup = Application.CreateTagGroup(Me.AreaName)
MyTagGroup.Add "system\Year"
MyTagGroup.Add "[SWTP_PLC001]A30AIT001.Ntu"

Dim SourceErrFile, DestErrFile
Dim Tag1 As Tag
Dim Tag2 As Tag
Dim Mytime
'Set the tag objects
Set Tag1 = MyTagGroup.Item("system\Year")
Set Tag2 = MyTagGroup.Item("[SWTP_PLC001]A30AIT001.Ntu")

Fname = "C:\Users\7 User\Documents\test.xls" 'name of already created excel project

Set ObjExcelApp = CreateObject("Excel.Application")
ObjExcelApp.Visible = False
ObjExcelApp.Workbooks.Open (Fname)

ObjExcelApp.WorkSheets("Sheet1").cells(1, "A").Value = Tag1.Value
ObjExcelApp.WorkSheets("Sheet1").cells(1, "B").Value = Tag2.Value

ObjExcelApp.ActiveWorkbook.Save
ObjExcelApp.Workbooks.close
ObjExcelApp.Quit
Set ObjExcelApp = Nothing
Exit Sub
End Sub
 
Will take a little modification to work with FTView, but this works fine as an excel macro:
Function NextRow(sheetname, startingRow) As Integer
Dim x as double
dim y as double
x = startingRow 'In case you want to leave some blank rows between header and data
With Sheets(sheetName)
For y = x to 65535
If .Cells(y,1)="" Then
NextRow = y
Exit For
End If
Next
End With

End Function
 
Does it HAVE to be excel format? Why not just a standard CSV file that Excel can read? Then you can simply do file writes with append, such that new data goes to the end of the file.
 

Similar Topics

Hi all. Currently I'm working on a VBa script for FTView. I would like to understand a bit better about some commands. 1) What are the...
Replies
3
Views
595
Hi all. I'm running a VBA code on my FTView which is actually working, but everytime I open the display that calls the VBA code, it throws the...
Replies
28
Views
1,801
Greetings, I have this question: How can I add a tag, in my case LS:0 {#5} (literal string of tag #5), to a variable using VBA? I couldn't find...
Replies
4
Views
894
Hello Every one, I need a help on vba code for getting data from MSSQL server 2014 to display in FTview SE client version 12 . Thanks. Please...
Replies
4
Views
1,811
I've been messing around with trying to find a way to clear all PlantPAx AOI latched alarms via the Alarm Banner or Summary objects. So far, I can...
Replies
2
Views
1,734
Back
Top Bottom