Page 1 of 1

VBScript Error messages...

PostPosted: Wed Dec 10, 2008 2:40 pm
by David de Argentina
Hi Dave,

I'm trying to catch error messages in VBScript functions.
But the debug mode doesn't provide any kind of information.
In fact, is very complicated search any error when the alertbox with the vbscript error starts.

Coud you add some info about VBScript error messages ?

(Line number, executed code, etc)

Thanks in advance,
David de Argentina

PostPosted: Wed Dec 10, 2008 5:48 pm
by Neosoft Support
Possibly. I'll add it to the list of things to look into for a future update.

PostPosted: Fri Dec 12, 2008 5:15 am
by David de Argentina
Thanks Dave,

For example: try this code:

Code: Select all
Dim ExcelSheet

Set ExcelSheet = CreateObject("Excel.Sheet")
' Make Excel visible through the Application object.
ExcelSheet.Application.Visible = True
' Place some text in the first cell of the sheet.
ExcelSheet.Application.Cells(1, 1).Value = "This is column A, row 1"
' Save the sheet to C:\test.xls directory.
ExcelSheet.SaveAs "C:\TEST.XLS"
' Close Excel with the Quit method on the Application object.
ExcelSheet.Application.Quit
' Release the object variable.
Set ExcelSheet = Nothing


On my XP SP3 machine I received this message:

"Required Object does not exist"

I don't know what line of code produces this errror.

Thanks again,
David de Argentina

PostPosted: Fri Dec 12, 2008 6:30 am
by Gaev
David de Argentina:

In desperation, you might try (like I do) the "Brute Force School of Debugging" ... add one command to the VBScript and run your program ... repeat until the error pops up.

BTW, does this same script work from inside another program ? ... I have not played with Excel Object ... but I don't see where you create a new WorkSheet first (or read one within an existing .xls file).

Gaev

PostPosted: Fri Dec 12, 2008 6:55 am
by dpayer
David de Argentina wrote:Thanks Dave,

For example: try this code:

Code: Select all
Dim ExcelSheet

Set ExcelSheet = CreateObject("Excel.Sheet")
' Make Excel visible through the Application object.
ExcelSheet.Application.Visible = True
' Place some text in the first cell of the sheet.
ExcelSheet.Application.Cells(1, 1).Value = "This is column A, row 1"
' Save the sheet to C:\test.xls directory.
ExcelSheet.SaveAs "C:\TEST.XLS"
' Close Excel with the Quit method on the Application object.
ExcelSheet.Application.Quit
' Release the object variable.
Set ExcelSheet = Nothing


On my XP SP3 machine I received this message:

"Required Object does not exist"

I don't know what line of code produces this errror.

Thanks again,
David de Argentina


I would think this specific object requires Excel to be on the machine you are working with. Do you have Excel on this machine?

Here is an old thread that states you need to use createobject("Excel.Application")

http://www.developerfusion.com/forum/thread/16057/

Code: Select all
you got to set a reference to "Microsoft Excel 10.0 Object Library"
or instead you can  write:
Dim ExcelSheet
set ExcelSheet=createobject("Excel.Application")


David P

PostPosted: Fri Dec 12, 2008 4:39 pm
by Neosoft Support
On my PC I get the following error:

ActiveX component can't create object: 'Excel.Sheet'

I do not have Excel installed.

PostPosted: Fri Dec 12, 2008 6:33 pm
by Gaev
David de Argentina:

I Googled vbscript create object Excel ... got a few good results but this one might be the most useful ...

http://www.activexperts.com/activmonito ... ice/excel/

... basically, it looks like you have to CreateObject("Excel.Application") ... then ...

- either objExcel.Workbooks.Add to add a WorkBook in a new Spreadsheet file

- or objExcel.Workbooks.Open("C:\yourFile.xls") to open an existing file