+ Reply to Thread
Results 1 to 4 of 4

Question: File already exists

  1. #1
    Michael Vaughan
    Guest

    Question: File already exists

    Hello Everyone,

    I have written a macro so that it formats some code, creates another
    workbook, and then saves the code to the harddrive. It all works fine, but
    I want to save it to the same file name everytime. Is there a command that
    I can write that will AUTOMATICALLY save the file and overwrite the file???
    After the script runs, then a msgbox pops up and always asks, "calander.csv
    already exists, do you want to overwrite??" Can I write some code that will
    do that? Here is the code I have now:

    ChDir "C:\Program Files\InternetMacros\Downloads"
    ActiveWorkbook.SaveAs Filename:= _
    "C:\Program Files\InternetMacros\Downloads\calander.csv",
    FileFormat:=xlCSV, _
    CreateBackup:=False

    Any help would be greatly appreciated,

    Michael Vaughan



  2. #2
    Dave Peterson
    Guest

    Re: Question: File already exists

    application.displayalerts=false
    'your code here
    application.displayalerts=true


    Michael Vaughan wrote:
    >
    > Hello Everyone,
    >
    > I have written a macro so that it formats some code, creates another
    > workbook, and then saves the code to the harddrive. It all works fine, but
    > I want to save it to the same file name everytime. Is there a command that
    > I can write that will AUTOMATICALLY save the file and overwrite the file???
    > After the script runs, then a msgbox pops up and always asks, "calander.csv
    > already exists, do you want to overwrite??" Can I write some code that will
    > do that? Here is the code I have now:
    >
    > ChDir "C:\Program Files\InternetMacros\Downloads"
    > ActiveWorkbook.SaveAs Filename:= _
    > "C:\Program Files\InternetMacros\Downloads\calander.csv",
    > FileFormat:=xlCSV, _
    > CreateBackup:=False
    >
    > Any help would be greatly appreciated,
    >
    > Michael Vaughan


    --

    Dave Peterson

  3. #3
    Tom Ogilvy
    Guest

    Re: Question: File already exists

    ChDir "C:\Program Files\InternetMacros\Downloads"
    Application.displayAlerts = False
    ActiveWorkbook.SaveAs Filename:= _
    "C:\Program Files\InternetMacros\Downloads\calander.csv",
    FileFormat:=xlCSV, _
    CreateBackup:=False
    Application.DisplayAlerts = True

    or
    Dim sStr as String
    ChDir "C:\Program Files\InternetMacros\Downloads"
    sStr = "C:\Program Files\InternetMacros\Downloads\calander.csv"
    On Error Resume Next
    Kill sStr
    On Error goto 0
    ActiveWorkbook.SaveAs Filename:=sStr, _
    FileFormat:=xlCSV, _
    CreateBackup:=False

    --
    Regards,
    Tom Ogilvy


    "Michael Vaughan" <michael@mvaughan.net> wrote in message
    news:Db2dnRnbr4oGxSzenZ2dnUVZ_tOdnZ2d@comcast.com...
    > Hello Everyone,
    >
    > I have written a macro so that it formats some code, creates another
    > workbook, and then saves the code to the harddrive. It all works fine,

    but
    > I want to save it to the same file name everytime. Is there a command

    that
    > I can write that will AUTOMATICALLY save the file and overwrite the

    file???
    > After the script runs, then a msgbox pops up and always asks,

    "calander.csv
    > already exists, do you want to overwrite??" Can I write some code that

    will
    > do that? Here is the code I have now:
    >
    > ChDir "C:\Program Files\InternetMacros\Downloads"
    > ActiveWorkbook.SaveAs Filename:= _
    > "C:\Program Files\InternetMacros\Downloads\calander.csv",
    > FileFormat:=xlCSV, _
    > CreateBackup:=False
    >
    > Any help would be greatly appreciated,
    >
    > Michael Vaughan
    >
    >




  4. #4
    Michael Vaughan
    Guest

    Re: Thanks

    Thanks Dave and Tom!!
    :-)



+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1