Modify the excel sheet

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • veer
    New Member
    • Jul 2007
    • 198

    Modify the excel sheet

    hello expert
    i have a programe in which i want to modify or add new records in excel sheet
    but it opened read only and when ever i want to insert the record it give the message that give new name to save the changes
    is there any idea to modify the excel sheet my code is

    Set x1 = CreateObject("E xcel.Applicatio n")
    x1.Workbooks.Op en ("c:\var\var2.x ls")
    x1.Visible = True
    x1.Worksheets(1 ).Cells(10, 5) = "hello"
    'x1.ActiveWorkb ook.Save
    Set xl = Nothing
    Unload Me
    thanks
  • Muiz
    New Member
    • Nov 2007
    • 6

    #2
    Hi,

    may be this code will help..
    first add refrence for Excel

    Dim objXL As Excel.Applicati on
    Dim objWB As Excel.Workbook
    Dim objWS As Excel.Worksheet
    Set objXL = New Excel.Applicati on
    Set objWB = objXL.Workbooks .Open("C:\Docum ents and Settings\raj\De sktop\Value Card\Appreciati on.xls")
    Set objWS = objWB.Worksheet s(1)
    With objWS
    .Cells(17, 6) = Combo2.Text
    .Cells(20, 6) = Text1.Text
    objWB.Save
    objWB.Close
    End With
    Set objWS = Nothing
    Set objWB = Nothing

    Comment

    Working...