Mohands Posted September 1, 2021 Share Posted September 1, 2021 (edited) Dears , I have an issue running VBScript to convert csv to xlsx and apply formatting on it from PHP where WorkBook (WB) variable always is empty. VBScript file works fine from command line , Apache service running as Administrator. I use XAMPP 7.4.21 on windows 2016 VBScript Code: Dim file, WB With CreateObject("Excel.Application") On Error Resume Next For Each file In WScript.Arguments Set objFSO = CreateObject("Scripting.FileSystemObject") Set stdout = objFSO.GetStandardStream (1) Set stderr = objFSO.GetStandardStream (2) src_file = objFSO.GetAbsolutePathName(file) stdout.WriteLine src_file Set WB = .Workbooks.Open(src_file) if IsEmpty(WB) Then stdout.WriteLine "Yes" Else stdout.WriteLine "No" End If WB.Worksheets(1).Range("A1:H1").Interior.ColorIndex = 29 WB.Worksheets(1).Range("A1:H1").Font.ColorIndex = 2 WB.Worksheets(1).Range("A1:H1").Font.Bold = True WB.Worksheets(1).Range("A1:H1").Font.Size = 14 WB.SaveAs Replace(objFSO.GetAbsolutePathName(WB.FullName), ".csv", ".xlsx"), 51 WB.Close False Next .Quit End With PHP call : exec("cscript.exe csvToxlsx.vbs sector_19_Buildings.csv"); Edited September 1, 2021 by Mohands Quote Link to comment https://forums.phpfreaks.com/topic/313643-run-vbscript-from-php-issue/ Share on other sites More sharing options...
Barand Posted September 1, 2021 Share Posted September 1, 2021 I don't see any PHP in there. I'm tempted to issue a warning for use of foul language 😀 Please use code button when posting code. 1 Quote Link to comment https://forums.phpfreaks.com/topic/313643-run-vbscript-from-php-issue/#findComment-1589548 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.