Hi
I have to open an existing excel file and insert a row to it in a perticular position. can anyone help plz
Printable View
Hi
I have to open an existing excel file and insert a row to it in a perticular position. can anyone help plz
I have attach a sample project with this post.
I hope it is same as you want and will helps you !:)
And don't forget to add a referance of Microsoft Excel Library ( i have used Excel 11.0 Library)Code:
Dim Myex As Excel.Application
Dim Mysht As Excel.Worksheet
Dim MyBook As Excel.Workbook
Set Myex = New Excel.Application
Set MyBook = Myex.Workbooks.Open(App.Path & "\try.xls")
Set Mysht = MyBook.Worksheets(1)
Dim Rowsel As String
Rowsel = CStr(Text1.Text & ":" & Text1.Text)
Myex.Rows(Rowsel).Select
Myex.Selection.Insert Shift:=xlDown
Myex.Visible = True
Regards!
Hi harshaperla and rahul
To add ref of excel old means making project dependant.Eg by adding Excel olb 8.0 means ,prj ll execute on office 2000 only and not on 97.So instead of adding ref ,try to use CreateObject("Excel.Application") method , so that ur dependency ll b removed.
Now harshaperla u allow to open expected xls file using shellExcute API and allow the user to modify the file in excel app itself.And Befor closing the app through vb save that file.So i think its sumwht easy way to do this...
So if u require more clarification, plz let me no more details abt wht u want to do in ur application.
:-)
Dev-6