|
-
March 24th, 2004, 10:09 AM
#5
Open Excel file using the following (after including Excel Application in your reference: From Project Menu select Add Reference, select COM tab, select Excel Object, Press OK)
' After identifying the Excel file name from OpenFiledialog1)
dim Xl as new Excel.Application
dim Xlb as Excel.Workbook = Xl.Workbooks.Open(Openfiledialog1.filename)
Dim Xls as Excel.Worksheet=CType(Xlb.worksheets(1),Excel.worksheet)
'insert a row
Xls.rows("1:1").Insert
'Add headers
xls.cells(1,1).value="Column1"
xls.cells(1,2).value="Column2"
xls.cells(1,3).value="Column3"
...
..
'Save file with the same name
Xlb.save
Xls=nothing
Xlb.close(False)
Xlb=nothing
Xl.quit
Xl=nothing
' Now open the Excel file as before using OleDB ...
Good luck.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|