Results 1 to 10 of 10

Thread: Saving To Excel

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2004
    Location
    UK
    Posts
    43

    Saving To Excel

    Hi all,

    Dim xl As New Object
    Dim wb As Excel.Workbook
    Dim sh As Excel.Worksheet
    xl = CreateObject("excel.application")

    wb = xl.Workbooks.Open("c:\file.xls")

    sh = wb.Worksheets(1)
    sh.Name = "Bench-Marking DATABASE"

    With sh
    .Cells(2, 1).Value = "T"
    .Cells(2, 2).Value = "D"
    .Cells(2, 3).Value = "L"
    .Cells(2, 4).Value = "T"
    .Cells(2, 5).Value = "A"
    .Cells(2, 6).Value = "C"
    End With

    wb.save()

    i managed to save the file, but i always get this pop up window asking me to whether to save the file or not,
    is there a way i can do it, wihout having to see the small window.

    take care

  2. #2

    Thread Starter
    Member
    Join Date
    Jan 2004
    Location
    UK
    Posts
    43
    sorry that was bit vague,

    what i am trying to do, is to read and write back to EXCEL.

    but i want to save file automatically, without having to deal with the pop window asking user whether to save or not.....

    anyway to do that..

    thank you very much

  3. #3
    Hyperactive Member mudfish's Avatar
    Join Date
    Feb 2004
    Location
    Chit Chat
    Posts
    353
    You are closing excel in your program?
    Mudfish AKA Bowfin
    I can spell "If" all day right, just a coder!


    "Always do sober what you said you'd do drunk. That will teach you to keep your mouth shut." -- Ernest Hemingway

    Member of the ECCC

  4. #4

    Thread Starter
    Member
    Join Date
    Jan 2004
    Location
    UK
    Posts
    43
    yes, after writing the data into the excelsheet, i want to exit vb. net, and excel

  5. #5
    Hyperactive Member mudfish's Avatar
    Join Date
    Feb 2004
    Location
    Chit Chat
    Posts
    353
    You shell excell and add data to a spread sheet that is stored?
    Do you have excell set to be visible?
    You can make it not visible!
    I am not a good . net person yet I see if I can find the command in .net!
    Last edited by mudfish; Mar 8th, 2004 at 09:45 AM.
    Mudfish AKA Bowfin
    I can spell "If" all day right, just a coder!


    "Always do sober what you said you'd do drunk. That will teach you to keep your mouth shut." -- Ernest Hemingway

    Member of the ECCC

  6. #6

    Thread Starter
    Member
    Join Date
    Jan 2004
    Location
    UK
    Posts
    43
    i dont' know,

    how could i change it to invisible

  7. #7
    Hyperactive Member mudfish's Avatar
    Join Date
    Feb 2004
    Location
    Chit Chat
    Posts
    353
    found this in help

    xlSheet.Application.Visible = True ' Show the application.


    search " Excel.Worksheet"

    I have .net 1
    Mudfish AKA Bowfin
    I can spell "If" all day right, just a coder!


    "Always do sober what you said you'd do drunk. That will teach you to keep your mouth shut." -- Ernest Hemingway

    Member of the ECCC

  8. #8

    Thread Starter
    Member
    Join Date
    Jan 2004
    Location
    UK
    Posts
    43
    i am still gettting the pop window to ask me whether i want to save the file or not,,,,,

    id ont' know what to do,,,

    thank you very much

  9. #9
    Hyperactive Member mudfish's Avatar
    Join Date
    Feb 2004
    Location
    Chit Chat
    Posts
    353
    In the save command there should be away to tell excell to save and close, let me look some more in help!

    From help

    Example
    This example uses the CreateObject function to set a reference (xlApp) to Microsoft Excel. It uses the reference to access the Visible property of Microsoft Excel, and then uses the Microsoft Excel Quit method to close it. Finally, the reference itself is released.
    Last edited by mudfish; Mar 8th, 2004 at 10:05 AM.
    Mudfish AKA Bowfin
    I can spell "If" all day right, just a coder!


    "Always do sober what you said you'd do drunk. That will teach you to keep your mouth shut." -- Ernest Hemingway

    Member of the ECCC

  10. #10

    Thread Starter
    Member
    Join Date
    Jan 2004
    Location
    UK
    Posts
    43
    i think i've cracked it
    i've used this mate :

    wb.close savechanged:=true

    wb is the workbook


    thank you very much for helping

    take care

    god bless

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