VB CreateObject example fails 
Author Message
 VB CreateObject example fails

Hi,

I've been trying to get to following example to work. It comes from the
VB 5 help file, search string CreateObject.

' Declare an object variable to hold the object
' reference. Dim as Object causes late binding.
Dim ExcelSheet As Object
Set ExcelSheet = CreateObject("Excel.Sheet")

This code starts the application creating the object, in this case, a
Microsoft Excel spreadsheet. Once an object is created, you reference it
in code using the object variable you defined. In the following example,
you access properties and methods of the new object using the object
variable, ExcelSheet, and other Microsoft Excel objects, including the
Application object and the Cells collection.

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

The error I'm getting is 'Runtime error 438, Object doesn't support the
property or method'. The error occurs in the line
ExcelSheet.Cells(1, 1).Value = "This is column A, row 1"

Anyone know how to get this working ?
Also how can I see which methods/properties are available for a given
object ? Isn't there some window that can popup telling what
methods/properties I can use with the ExcelSheet object ?

Thanks,

Ronan van Riet



Tue, 07 Nov 2000 03:00:00 GMT  
 VB CreateObject example fails

Ronan,


blank body. It may be relevant to your problem.

Basically, if you are using different versions of Excel, either a sheet or
a workbook will be returned using CreateObject("Excel.Sheet"). I am
guessing that you are using Excel 97 and that this is your problem.

And that reminds me, always try and tell us which version of an app (eg.
Excel) you are using.

Matthew



Quote:
> Hi,

> The error I'm getting is 'Runtime error 438, Object doesn't support the
> property or method'. The error occurs in the line
> ExcelSheet.Cells(1, 1).Value = "This is column A, row 1"

> Anyone know how to get this working ?
> Also how can I see which methods/properties are available for a given
> object ? Isn't there some window that can popup telling what
> methods/properties I can use with the ExcelSheet object ?

> Thanks,

> Ronan van Riet



Tue, 07 Nov 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Michael Harris: Question re Your GetObject/CreateObject examples

2. CreateObject Sometimes silently fails

3. call to Server.CreateObject failed ? please help

4. CreateObject fails - sometimes

5. SMTP mail via ASP: CreateObject CDONTS fails

6. CreateObject in VisualStudio fails!

7. CreateObject("Excel.Application") Fails on NT

8. CreateObject Fails

9. Server.CreateObject fails

10. CreateObject fails!

11. Wscript CreateObject Fails!

12. Server.CreateObject failed - out of memory

 

 
Powered by phpBB® Forum Software