
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