Source language: Translate to:

VBScript Error messages...

Post your suggestions for future versions of NeoBook

Moderator: Neosoft Support

VBScript Error messages...

Postby David de Argentina » Wed Dec 10, 2008 2:40 pm

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
User avatar
David de Argentina
 
Posts: 1562
Joined: Mon Apr 04, 2005 4:13 pm
Location: Buenos Aires, Argentina

Postby Neosoft Support » Wed Dec 10, 2008 5:48 pm

Possibly. I'll add it to the list of things to look into for a future update.
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5605
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

Postby David de Argentina » Fri Dec 12, 2008 5:15 am

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
User avatar
David de Argentina
 
Posts: 1562
Joined: Mon Apr 04, 2005 4:13 pm
Location: Buenos Aires, Argentina

Postby Gaev » Fri Dec 12, 2008 6:30 am

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
User avatar
Gaev
 
Posts: 3737
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby dpayer » Fri Dec 12, 2008 6:55 am

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
User avatar
dpayer
 
Posts: 1384
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

Postby Neosoft Support » Fri Dec 12, 2008 4:39 pm

On my PC I get the following error:

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

I do not have Excel installed.
Last edited by Neosoft Support on Mon Dec 15, 2008 5:02 pm, edited 1 time in total.
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5605
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

Postby Gaev » Fri Dec 12, 2008 6:33 pm

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
User avatar
Gaev
 
Posts: 3737
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada


Return to NeoBook Suggestions

Who is online

Users browsing this forum: No registered users and 1 guest