6/12/2024 7:31 AM | |
Joined: 11/28/2023 Last visit: 1/30/2025 Posts: 25 Rating:
|
Hi guys, I want to write data to an xlsx file on a USB stick connected to my TP900 using a VB script. I managed to do it on a Runtime but It doesn't work on my TP900 Comfort. My script is : 'Local variable Dim objExcel, objWorkbook, count, check count = 2 check = 0 'Excel instance Set objExcel = CreateObject("Excel.Application") 'Open Excel Set objWorkbook = objExcel.Workbooks.Open("\Storage Card USB\Tracabilite.xlsx") 'Check line to write value Do Until check = 1 If objExcel.Cells(count,1).Value = "" Then check = 1 Else count = count + 1 check = 0 End If Loop 'Write value objExcel.Cells(count,1).Value = SmartTags ("Reference") objExcel.Cells(count,2).Value = SmartTags ("Date") objExcel.Cells(count,3).Value = SmartTags ("Heure") objExcel.Cells(count,4).Value = SmartTags ("Resultat_photo") objExcel.Cells(count,5).Value = SmartTags ("Val_P1_CT") objExcel.Cells(count,6).Value = SmartTags ("Val_P1_RD") objExcel.Cells(count,7).Value = SmartTags ("Val_P3_CT") objExcel.Cells(count,8).Value = SmartTags ("Val_P3_RD") objExcel.Cells(count,9).Value = SmartTags ("Resultat_test_LED") objExcel.Cells(count,10).Value = SmartTags ("Num_etq") objExcel.Cells(count,11).Value = SmartTags ("Num_lot") 'Save Excel objWorkbook.Save 'Close Excel objWorkbook.Close 'Free Excel objExcel.Quit 'Free objects Set objExcel = Nothing Set objWorkbook = Nothing count = 2 check = 0 Tracabilite_OK = 1 End If I found this page that explain few things but I didn't understand 3 things : https://support.industry.siemens.com/cs/fr/en/view/59604194 1) What's the difference between CreateObject (Excel.Application) and (FileCtl.File) ? I found (FileCtl.Application) too. 2) What should I put on delimiter and gap ? It says that it depends on country but nothing more is explained .. is there a documentation somewhere ? 3) How can I choose which line/column to write values ? I did it with a "count" variable but if my syntax is wrong, I must changed it. For now I can't test on the physical HMI so i'll try to simulate it or something, if it's possible. Thanks for your help, BR |
Last edited by: Lucas_Clavé at: 06/12/2024 07:32:45Last edited by: Lucas_Clavé at: 06/12/2024 07:33:21Last edited by: Jen_Moderator at: 06/12/2024 11:03:50Link optimized. |
|
Follow us on