Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel in Visual Basic

Status
Not open for further replies.

rikeman

Programmer
Sep 18, 2004
40
BE
Hi,

I would like to make a visual basic 6 application that works with excel :

There is a textbox and a command button, and when I write something in the textbox and I've clicked on the command button, the application must save the text in the textbox in an excel document (ex. in cell A5, and excel document "c:\new\test.xls"). Can someone help me?

Greetz.
 
Dim ExcelApp As Object
Dim ExcelWorkbook As Object
Set ExcelApp = CreateObject("Excel.Application")
Set ExcelWorkbook = ExcelApp.Workbooks.Add
With ExcelWorkbook.Sheets(1)
Range("A5").Value = YourTextboxValue
End With
ExcelWorkbook.SaveAs 'Turn on the macro recorder and
'save a workbook to see options
ExelApp.Quit
Set ExcelApp = Nothing: Set ExcelWorkbook = Nothing

This is pretty close and should get you started. If you set a reference to the Excel library objects, you can use the object browser and intellisense to finish it off. Good Luck!

Have a great day!

j2consulting@yahoo.com
 
Thanx for your answer!
But how must I open an excisting excel document and write something in a cell?

Greetz.
 
Hi,

Use GetObject. Check the help on GetObject regarding checking the existance of an open Excel application.

Skip,

[glasses] [red]Be advised:[/red] When transmitting sheet music...
If it ain't baroque, don't fax it! [tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top