VBA for FactoryTalk SE

IK-Trading

Member
Join Date
Mar 2015
Location
Randers
Posts
3
I have an application which, as has been running for many years. It is made in RSVIEW where I use VBA to write to an Excel file.
I have rewritten aplicationen to FactoryTalk SE.
VBA in FT SE. is apparently similar to that of RSView.
I can not close an Excel file without having to acknowledge each time.
Is it possible to replace the VBA part, to that of RSView32?
 
It's short, because that is the answer. The way VBA works even in RSView32 and FTViewSE is completely different. There is no reason you should have to manually close an Excel file though no matter which you use, unless something has changed with Excel itself.
 
How is it that you are saving to an excel file? Is it a CSV? And what kind of acknowledgement to you have to provide? The description of your issue is a bit vague.
What does your VBA code look like?
 
I am sorry if my description was a little vague.
I must for every minute log some production data.
outside there is staff to acknowledge closing the excel file.
I have read it in RSView32 without having to acknowledge with this code.

Sub LogValue()
Dim ExcelApp As Excel.Application
Dim ExcelWorkBook As Excel.Workbook
Dim ExcelWasNotRunning As Boolean
Dim objExcel As Object
Dim iCounterRawNumber As Integer
Dim iCounterWorkTime As Integer
Dim tLastRowNumber As Tag
Dim tWorktime As Tag
Dim ***celFilePath As String

' Path til rapport
***celFilePath = gProject.Path & NewFilePath & gTagDb.GetTag("Excel\Jobname").Value & ".xls"


On Error Resume Next ' Defer error trapping.

'Set the object variable to reference the file you want to see.
Set ExcelApp = New Excel.Application
Set ExcelWorkBook = ExcelApp.Workbooks.Open(***celFilePath)

'Find last row number
Set tLastRowNumber = gTagDb.GetTag("Excel\LastRowNumber")

With tLastRowNumber

iCounterRawNumber = .Value
'New raw number
iCounterRawNumber = iCounterRawNumber + 1

'Save new row number
.Value = iCounterRawNumber

End With

'Find last worktime number
Set tWorktime = gTagDb.GetTag("Excel\Worktime")

With tWorktime

iCounterWorkTime = .Value
'New raw number
iCounterWorkTime = iCounterWorkTime + 1
' Gem WorkTime i PLC integer
gTagDb.GetTag("Excel\PLCWorkTime").Value = iCounterWorkTime
'Save new row number
.Value = iCounterWorkTime

End With


' Show Microsoft Excel through its Application property. Then
' show the actual window containing the file using the Windows
' collection of the MyXL object reference. Remove the single
' quotes from the next two lines to make Excel visible.

'Populate the Excel Spreadsheet
With ExcelWorkBook.Worksheets("Logdaten")

'Write the data to Excel
.Cells(iCounterRawNumber, 1).Value = gTagDb.GetTag("Excel\Worktime").Value
.Cells(iCounterRawNumber, 2).Value = gTagDb.GetTag("AKT\N10_5").Value
.Cells(iCounterRawNumber, 3).Value = gTagDb.GetTag("AKT\N10_6").Value
.Cells(iCounterRawNumber, 4).Value = gTagDb.GetTag("AKT\N10_13").Value
.Cells(iCounterRawNumber, 5).Value = gTagDb.GetTag("AKT\N10_14").Value
.Cells(iCounterRawNumber, 6).Value = gTagDb.GetTag("AKT\N10_1").Value
.Cells(iCounterRawNumber, 7).Value = gTagDb.GetTag("AKT\N10_3").Value
.Cells(iCounterRawNumber, 8).Value = gTagDb.GetTag("AKT\N10_0").Value
.Cells(iCounterRawNumber, 9).Value = gTagDb.GetTag("AKT\N10_4").Value
.Cells(2, 15).Value = gTagDb.GetTag("Excel\StopTime").Value
End With

' Save and close Ecxel
ExcelApp.ActiveWorkbook.Save
ExcelApp.ActiveWorkbook.Saved = True
ExcelApp.Quit

'Release reference to the application and spreadsheet.
Set ExcelWorkBook = Nothing
Set ExcelApp = Nothing

End Sub

FactoryTalk will not be known by the code, and all other attempts have been in vain.
Any suggestions?
 

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
35
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
80
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,806
Back
Top Bottom