Results 1 to 9 of 9

Thread: SaveAs Excel

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2003
    Posts
    124

    SaveAs Excel

    How do i SaveAs even if the file already exists.
    I have this, but i still get the "Are you sure you want to overwrite..." from Excel

    oWB.SaveAs("Filename.xls" , , , , , , Excel.XlSaveConflictResolution.xlLocalSessionChanges)

    How do i use the saveAs method without needing to prompt the user?

    thx

    db

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

    Re: SaveAs Excel

    Try something like this :

    VB Code:
    1. Dim sv As New SaveFileDialog
    2. sv.OverwritePrompt = False

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jun 2003
    Posts
    124
    Pirate,

    I'm not using a Dialog, im using the SaveAs method of the workbook object.

    regards

    db

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Sorry , got no clue about this .

  5. #5
    Frenzied Member <ABX's Avatar
    Join Date
    Jul 2002
    Location
    Canada eh...
    Posts
    1,622
    do you want to save to the same file that you are working on?

    VB Code:
    1. xl.Workbooks(1).Save


    If not just make a FileExist function and if the path exists delete it.
    Tips:
    • Google is your friend! Search before posting!
    • Name your thread appropriately... "I Need Help" doesn't cut it!
    • Always post your code!!!! We can't read your mind!!! (well, at least most of us!)
    • Allways Include the Name and Line of the Exception (if one is occuring!)
    • If it is relevant state the version of Visual Studio/.Net Framwork you are using (2002/2003/2005)


    If you think I was helpful, rate my post
    IRC Contact: Rizon/xous ChakraNET/xous Freenode/xous

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Jun 2003
    Posts
    124
    no, diff file name

    maybe i can delete the old file then saveAs, this way i wouldnt have to worry about getting prompted about the overwrite.

    I think an If statement seeing if the file exists, then delete if True would do the trick.

    So yeah, how do i delete a file?

    thx db

  7. #7
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    This is how to delete the file by passing the path & file name . I still don't get why you want to overwrite the file without promoting the user. I'm all Windows editions and all professional app behave this way . Give your user the choice and don't force him to do weird stuff .

    VB Code:
    1. File.Delete(path)

  8. #8
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Opps , don't forget to include this at the very top of your form or a class where you'll use this function :

    VB Code:
    1. Imports System.IO

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Jun 2003
    Posts
    124
    P,

    I'm not prompting the user because this is a program that captures write speed to Network Drives.

    Thanks for the IO stuff, it works fine now

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