Open and edit excel files using VB6
Can someone please let me know how I could open an excel file and then do the insert. I am not an expert in this area, please give me an example which will help me do that. I have a file and would like to insert some rows after every line based on a logic.
Please help me asap!!!
Re: Open and edit excel files using VB6
Re: Open and edit excel files using VB6
To get you started...
VB Code:
Option Explicit
'Add a reference to MS Excel xx.0 Object Library
Private Sub Command1_Click()
Dim oApp As Excel.Application
Dim oWB As Excel.Workbook
'Create an Excel instalce.
Set oApp = New Excel.Application
'Open the desired workbook
Set oWB = oApp.Workbooks.Open(FileName:="C:\test.xls")
'Do any modifications to the workbook.
'...
'Save the xls file
oWB.SaveAs FileName:="C:\test.xls"
'close and clean up resources
oWB.Close SaveChanges:=False
Set oWB = Nothing
oApp.Quit
Set oApp = Nothing
End Sub