damienm
asked on
Excel object
I have this code which I copyed straight from the help files
Private Sub Command1_Click()
' Declare an object variable to hold the object
' reference. Dim as Object causes late binding.
Dim ExcelSheet As Object
Set ExcelSheet = CreateObject("Excel.Sheet" )
ExcelSheet.Application.Vis ible = 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:\temp\TEST1.xls"
' Close Excel with the Quit method on the Application object.
ExcelSheet.Application.Qui t
' Release the object variable.
Set ExcelSheet = Nothing
End Sub
but when it gets to the line
ExcelSheet.Cells(1, 1).Value = "This is column A, row 1"
I get the error message "Object doesn't support this message or property"
Private Sub Command1_Click()
' Declare an object variable to hold the object
' reference. Dim as Object causes late binding.
Dim ExcelSheet As Object
Set ExcelSheet = CreateObject("Excel.Sheet"
ExcelSheet.Application.Vis
' 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:\temp\TEST1.xls"
' Close Excel with the Quit method on the Application object.
ExcelSheet.Application.Qui
' Release the object variable.
Set ExcelSheet = Nothing
End Sub
but when it gets to the line
ExcelSheet.Cells(1, 1).Value = "This is column A, row 1"
I get the error message "Object doesn't support this message or property"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
skyblue changed the proposed answer to a comment
Thanks, skyblue!
it's the first time i have ever posted anything. i was surprised to see your answer popup a minute before mine!
it's the first time i have ever posted anything. i was surprised to see your answer popup a minute before mine!
Welcome to EE, skyblue! It's good to see that you are beginning to post solutions. Keep at it! You'll beat me next time...
It was nice of you to withdraw your answer when you noticed my post with the same solution.
/Ture
It was nice of you to withdraw your answer when you noticed my post with the same solution.
/Ture
.. and maybe i'll know not to press refresh next time!
ASKER
Hardluck Skyblue a few seconds earlier and you would have 50 points,
Thanks Ture, Skyblue
Thanks Ture, Skyblue
ExcelSheet.Sheets(1).Cells
You can get help on the Excel Application object properties and methods by adding a reference to the Microsoft Excel Object Library in your project and using the object browser (press F2).