Discussion Locked

Using Excel From VB6

0 helpful
9 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I want to wite some data in existing excel
workbook from my program i making it with VB6
I have wrtie code like this :
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.Cells(1, 1).Value = "This is column A, row 1"
' Save the sheet to C:\test.doc 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

but it's not work it's give me error massge
for this line ExcelSheet.Cells(1, 1).Value = "This is it says the properaty not support

so what can ido to make what i need?

9 replies

by leirags

Be more imagination (sorry above the terminology)

but you can assign a value just with assign like a every program on the world

If you like a string contents on the cells then
Cells(1,1) = " juanito "

If you like a integer contents on the cells then
Cells(1,1) = 123

If you like a date contents on the cells then
Cells(1,1) = "01/02/2000"
On this is automatic convet to DATE for excel

and so on

by cfburgess

Try this
ExcelSheet.Worksheets(1).Cells(1, 1).Value = "This is column A, row 1"

ExcelSheet refers to only the workbook.

by cfburgess

The posted answer resolves the specific error as stated in your question.
What is not complete about it? The code, with the change, executes in VB6.

by khalid

you didn't tell me about the obejct library i need to add it to VB
and you didn't tell me about the file
i want to write in it

This discussion is closed to new replies.