Le stockage des Données de WinCC Flex de fichier Excel à l'aide de VBScript

Suis en train d'enregistrer les données de certains tags de WinCC Flex en fichier Excel à l'aide de VB Script.
J'ai cherché sur Siemens forums et ai un script en fonction de mes besoins.
Mais il y a une erreur lors de l'exécution du script dans WinCC Flex.

Le script est comme:

Dim wsh, XLSrunning, TargetBookrunning, objExcelApp, objWorkbook, TheTargetBook,    TheTargetBookName
Dim TheCount
Dim objFSO
Const OverwriteExisting = 1
Set wsh = CreateObject("WScript.Shell")
TheTargetBookName = "report.xls"
TheTargetBook = "D:\Out\" & TheTargetBookName
'---------------[Modification#1_Begin]-------------------------------------------
Set objFSO = CreateObject("Scripting.FileSystemObject")
If Not objFSO.FileExists(TheTargetBook) Then
objFSO.CopyFile "D:\Out\Template.xls", TheTargetBook, OverwriteExisting
'HMIRuntime.Trace "The file," & TheTargetBook & ", does not exist." & vbCrLf & "I've just created one for you!"
End If
Set objFSO = Nothing    
'---------------[Modification#1_End]--------------------------------------------
TheCount = GetObject("winmgmts:root\CIMV2").ExecQuery("SELECT * FROM Win32_Process WHERE Name='EXCEL.EXE'").Count   
'While TheCount is bigger than 0, it means the Excel Application is running..., but doesn't mean the workbook is open for sure!
If TheCount > 0 Then
Set objExcelApp = GetObject(,"Excel.Application")
' Using GetObject(,"Excel.Application") to point to the running Excel Application.
TargetBookrunning = 0  
For Each XLSrunning In objExcelApp.Workbooks
If XLSrunning.name = TheTargetBookName Then
TargetBookrunning = 1
End If
Next
If TargetBookrunning = 1 Then
Set objWorkbook = GetObject(TheTargetBook)
Else
Set objWorkbook = objExcelApp.Workbooks.Open(TheTargetBook)
End If
Else
Set objExcelApp = CreateObject("Excel.Application")
Set objWorkbook = objExcelApp.Workbooks.Open(TheTargetBook)
End If
objExcelApp.Visible = True
objExcelApp.ScreenUpdating = True
objExcelApp.DisplayAlerts = True
Dim TheTargetRow       ' <------[Modification#2]-------
With objWorkbook.ActiveSheet
TheTargetRow = .Cells(65535, 2).End(-4162).Row
.cells(TheTargetRow + 1, 2) = SmartTags("Tag_1")
.cells(TheTargetRow + 1, 3) = SmartTags("Tag_2")
.cells(TheTargetRow + 1, 4) = SmartTags("Tag_3")         
End With 
objWorkbook.Save
'objWorkbook.Close
Set objWorkbook = Nothing
'objExcelApp.Quit
Set objExcelApp = Nothing
'MsgBox "Done"
Set wsh = Nothing   

Lorsque j'essaie d'exécuter ce script, le compilateur affiche l'erreur dans la ligne suivante:

 TheTargetRow = .Cells(65535, 2).End(-4162).Row

Suis incapable de déterminer l'erreur. Merci de faire le nécessaire.

InformationsquelleAutor Nitish Katal | 2013-05-09