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?