I am attempting to write a script for an application called Syspro that uses VBScript as a means to extend the functionality of the product. The script I'm working on is supposed to take a report generated by the program and output it into an excel spreadsheet. I am attempting to test code I've written so far to confirm functionality and am running into problems trying to create excel spreadsheets. I suspect I may have some permissions issue but do not exactly know where to look or how to check without trying to hamfist it by loosening all of my security settings.
I am testing this code in two different environments: as a web application in Visual Studio 2013 express, and as a script itself within the Syspro application. In both instances, my code takes an XML file and appropriately parses the data into a single multi-dimensional array, which is then passed into a function that creates the spreadsheet. The function that is not behaving properly I've reproduced below:
When I run this code in the VS2013 debugger, the script fails on "Set objExcel = CreateObject("Excel.Application")" and provides the error message in this post's subject line.
When I run this code in Syspro, the script actually completes; an excel file is created, properly named, and saved in the correct location. However the file is empty, containing no data.
I'm new to VBScripting, my development background is ColdFusion so I'm sure there's a fair amount of things I'm not accounting for here. All assistance is appreciated.
I am testing this code in two different environments: as a web application in Visual Studio 2013 express, and as a script itself within the Syspro application. In both instances, my code takes an XML file and appropriately parses the data into a single multi-dimensional array, which is then passed into a function that creates the spreadsheet. The function that is not behaving properly I've reproduced below:
Code:
Function createSheets(sArray)
Dim dateToday, strFileName
Dim objExcel
Dim i, j
dateToday = Month(Date) & "-" & Day(Date) & "-" & Year(Date)
strFileName = "C:\XML-AVGPRC-" & dateToday & ".xlsx"
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.DisplayAlerts = FALSE
objExcel.workbooks.Add
For i = 0 To UBound(sArray)
For j = 0 To UBound(sArray(i))
objExcel.Cells(i+1,j+1).Value = sArray(i)(j)
Next
Next
objExcel.ActiveWorkbook.SaveAs(strFileName)
objExcel.Quit
End FunctionWhen I run this code in Syspro, the script actually completes; an excel file is created, properly named, and saved in the correct location. However the file is empty, containing no data.
I'm new to VBScripting, my development background is ColdFusion so I'm sure there's a fair amount of things I'm not accounting for here. All assistance is appreciated.