WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

OLE with Excel
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

ObjectGet and Excel


Question:

I need to be able to open and display an Excel spreadsheet. This should be simple, what am I doing wrong? Excel does display, but without the spreadsheet.
oXLS=objectGet("C:\test.xls")
oApp=objectGet("Excel.Application")
oApp.visible=@true

Answer:

oApp=objectGet(,"Excel.Application")
oApp.visible=@true
oApp.Workbooks.Open("C:\test.xls")

User Reply:

I'm still trying to understand the ObjectGet function. Look at the two scripts below. Both email the spreadsheet as an attachment, but the attachment sent by the first script only opens Excel. It does not show the workbook. The second one works fine. What is missing from the first script that causes the workbook not to be displayed when opened?
oXLS=objectGet("C:\test.xls")
oXLS.sendMail("John Eudy")
exit

oApp=objectCreate("Excel.Application")
oXLS=oApp.Workbooks.Open("C:\test.xls")
oXLS.SendMail("John Eudy")
exit

Answer:

The behavior you observe has very little to do with the GetObject function and almost everything to do with how MSFT chose to implement Excel COM objects. The 2004B help files covers the GetObject/ObjectGet function in some detail. If you want a different ( and, IMHO, less informative) discussion of the GetObject function check out MSFT description in the their VBS documentation. The behavior for both VBS and WB versions of the function is nearly identical.

http://support.microsoft.com/kb/288902


Article ID:   W16622
File Created: 2010:09:23:08:15:16
Last Updated: 2010:09:23:08:15:16