CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2004
    Location
    Bangalore,karnataka,India
    Posts
    13

    Editing Excel file from Vb

    Hi
    I have to open an existing excel file and insert a row to it in a perticular position. can anyone help plz

  2. #2
    Join Date
    Sep 2005
    Location
    Delhi, INDIA
    Posts
    237

    Red face Re: Editing Excel file from Vb

    I have attach a sample project with this post.
    I hope it is same as you want and will helps you !


    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
    And don't forget to add a referance of Microsoft Excel Library ( i have used Excel 11.0 Library)

    Regards!
    Attached Files Attached Files
    I'M BACK AGAIN !!
    -------------------------------------------------------------------------
    enjoy the VB !
    If any post helps you, please rate that.
    Always try to findout the Solutions, instead just discussing the problem and its scope!

  3. #3
    Join Date
    May 2005
    Posts
    42

    Re: Editing Excel file from Vb

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured