MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Saving Data into Excel from VB form


Posted by Anand on February 08, 2001 5:52 AM

Hi All ,

I need to edit an excel file ( which is populated from an MSSQL table ) from a VB form and then save the changes to the excel from which I will have to store the data back into an SQL table . The ole container was an option but it does not seem to save changes to the excel sheet . can anybody help me.


Posted by jp on February 08, 2001 11:51 AM

I'm new at this, so don't laugh too loud.
This might work to edit Excel file from VB....
- - - - - - - - - - - - - -
dim objects etc......
-
' path = path and Excel filename
set xlfile = GetObject(path)
-
set xlsheet = xlsfile.Sheets(sheetname)
set xlapp = xlsheet.Application
' here prog if you want visible etc...
' enter in data from other sourse - ?VB
xlapp.Range("A1???") = vardata
-
-
'then save/close Xl file etc.
- - - - - - - - - - - - - -