1/7/2025 7:27 AM | |
Joined: 1/6/2025 Last visit: 2/10/2025 Posts: 1 Rating:
|
i'm try to create excel report for vb script but only create the folder dosen't create the excel Sub OnClick(ByVal item) 'Tip: ' 1. Use the <CTRL+SPACE> or <CTRL+I> shortcut to open a list of all objects and functions ' 2. Write the code using the HMI Runtime object. ' Example: HmiRuntime.Screens("Screen_1"). ' 3. Use the <CTRL+J> shortcut to create an object reference. 'Write the code as of this position: Dim folderway,objectway, filename, file, fileeits, apendix, row folderway = "C:\Users\PDE-Automation-ACER\Music\report" Set objectway = CreateObject("scripting.filesystemobject") If Not objectway.FolderExists(folderway) Then objectway.CreateFolder folderway End If filename = "report.xlsx" Set file = CreateObject("scripting.filesystemoject") fileeits = file.fileeits(folderway & "\" & filename) If fileeits = False Then file.createtetfile(folderway &"\"& filename) Set file = Nothing End If End Sub request to solve this problem ------------------------------------------------------------------------------------------ |
Last edited by: U_ea44a9b6-5539-4061-9dd5-5892d7007313 at: 01/07/2025 07:29:48Last edited by: Moderator_Lan at: 01/07/2025 09:21:07New subject after splitting |
|
1/7/2025 11:04 AM | |
Joined: 4/26/2012 Last visit: 4/17/2025 Posts: 1629 Rating:
|
Hello, welcome to the forum. A quick look at the code. Review the syntax: Set file = CreateObject("scripting.filesystemoject") here should be CreateObject("Scripting.FileSystemObject") fileeits = file.fileeits(folderway & "\" & filename) here should be fileExists file.createtetfile(folderway &"\"& filename) here should be CreateTextFile "report.xlsx" try using .xls or .csv What device model are you using? good luck.
|
Last edited by: rdoliveira at: 01/07/2025 11:09:08edit Last edited by: rdoliveira at: 01/07/2025 11:09:59edit "Always make a backup before performing any tests |
|
1/10/2025 1:26 PM | |
Joined: 8/3/2009 Last visit: 4/17/2025 Posts: 15311 Rating:
|
Hello AutoGen_3037887 I think the filesysem and file object can only create textbased files. An Excel File you can only create with MS Automation Interface. - Using CSV File (Textbased): https://support.industry.siemens.com/cs/ww/en/view/106501825 - Using MS Automation Interface (MS Excel has to be installed on the System in 32 bit): https://support.industry.siemens.com/cs/ww/en/view/109792585/139193407371
Bye Murof |
If this Information really helps, you could use the Rate function |
|
This contribution was helpful to
1 thankful Users |
Follow us on