7/3/2020 4:11 AM | |
Joined: 8/17/2018 Last visit: 11/22/2024 Posts: 9 Rating:
|
Same problem with me when using plc bit got same value in excel. Anyone can help? Sub Excel_Line_1() Dim FolderWay, ObjectWay, FileName, File, FileExist, Appendix , Row 'Define FolderWay(Folder Path) FolderWay = "C:\Users\KSG\Documents\AUTO BATCHING\LINE 1" 'Create Object containing way to folder Set ObjectWay = CreateObject("Scripting.FileSystemObject") 'If folder not exist create it If Not ObjectWay.FolderExists(FolderWay) Then ObjectWay.CreateFolder FolderWay End If 'Define FileName with Date FileName = "\Batching_Report-" & CStr(DatePart("d",Date)) & "_" & CStr(DatePart("m",Date)) & "_" & CStr(DatePart("yyyy",Date)) &".xls" 'Create new object to control file existance Set File = CreateObject("Scripting.FileSystemObject") 'Check if file exist in defined folder way FileExist = File.FileExists(FolderWay & "\" & FileName) If FileExist = False Then 'Create file File.CreateTextFile(FolderWay & "\" & FileName) 'Set appendix of excel file Set Appendix = File.OpenTextFile(FolderWay & "\" & FileName,8) Appendix.WriteLine("Time Batch Recipe Latex(kg) Chemical_A(kg) Chemical_B(kg) Chemical_C(kg) Chemical_D(kg) Chemical_E(kg) Chemical_F(kg) Water(kg) Total(kg)") Appendix.Close 'Clear object Set File = Nothing End If Set File = CreateObject("Scripting.FileSystemObject") Set Row = File.OpenTextFile(FolderWay & "\" & FileName, 8) Row.WriteLine(""&Time & " "&SmartTags ("BATCHLINE1_Batch_No") & " "& SmartTags ("BATCHLINE1_Set_Recipe")& " "& SmartTags ("BATCHLINE1_L1_Latex")& " "& SmartTags ("BATCHLINE1_L1_ChemicalA")& " "& SmartTags ("BATCHLINE1_L1_ChemicalB")& " "& SmartTags ("BATCHLINE1_L1_ChemicalC")& " "& SmartTags ("BATCHLINE1_L1_ChemicalD")& " "& SmartTags ("BATCHLINE1_L1_ChemicalE")& " "& SmartTags ("BATCHLINE1_L1_ChemicalF")& " "& SmartTags ("BATCHLINE1_L1_Water")& " "& SmartTags ("BATCHLINE1_L1_Total")) Row.Close End Sub ------------------------------------------------------------------------------------------ |
Last edited by: Jen_Moderator at: 07/03/2020 10:38:45New subject after splitting |
|
7/6/2020 12:51 PM | |
Joined: 6/19/2017 Last visit: 9/6/2024 Posts: 8175 Rating:
|
Closed cause question posted twice. The second thread with the subject Need help with VB script is published within the conference SIMATIC WinCC (TIA Portal). Best regards,Jen_Moderator |
Follow us on