+ Reply to Thread
Results 1 to 3 of 3

Automatically overwriting files

  1. #1
    Sherwood
    Guest

    Automatically overwriting files

    Greetings,

    I have the following VBA code which saves a text file to a certain folder.
    However, if that file already exists, it displays a dialog box asking me if I
    want to overwrite the existing file. I always want to answer "Yes" to this
    dialog. However, I won't always know if a file by that same name already
    exists before the code is run. That means that the dialog will not always
    appear. I guess I could use Sendkeys, but that would only work if an
    existing file by that same name would always be in that folder. Any idea as
    to how to get around this?

    ActiveWorkbook.SaveAs Filename:="C:\filename.txt", FileFormat:=xlText, _
    CreateBackup:=False
    --

    Thanks in advance!
    Sherwood

  2. #2
    Ron de Bruin
    Guest

    Re: Automatically overwriting files

    Hi Sherwood

    Before the save
    Application.DisplayAlerts = False

    amd after the save
    Application.DisplayAlerts = True


    --
    Regards Ron de Bruin
    http://www.rondebruin.nl


    "Sherwood" <[email protected]> wrote in message news:[email protected]...
    > Greetings,
    >
    > I have the following VBA code which saves a text file to a certain folder.
    > However, if that file already exists, it displays a dialog box asking me if I
    > want to overwrite the existing file. I always want to answer "Yes" to this
    > dialog. However, I won't always know if a file by that same name already
    > exists before the code is run. That means that the dialog will not always
    > appear. I guess I could use Sendkeys, but that would only work if an
    > existing file by that same name would always be in that folder. Any idea as
    > to how to get around this?
    >
    > ActiveWorkbook.SaveAs Filename:="C:\filename.txt", FileFormat:=xlText, _
    > CreateBackup:=False
    > --
    >
    > Thanks in advance!
    > Sherwood




  3. #3
    Sherwood
    Guest

    Re: Automatically overwriting files

    Thanks, Ron. I appreciate it.
    --
    Sherwood


    "Ron de Bruin" wrote:

    > Hi Sherwood
    >
    > Before the save
    > Application.DisplayAlerts = False
    >
    > amd after the save
    > Application.DisplayAlerts = True
    >
    >
    > --
    > Regards Ron de Bruin
    > http://www.rondebruin.nl
    >
    >
    > "Sherwood" <[email protected]> wrote in message news:[email protected]...
    > > Greetings,
    > >
    > > I have the following VBA code which saves a text file to a certain folder.
    > > However, if that file already exists, it displays a dialog box asking me if I
    > > want to overwrite the existing file. I always want to answer "Yes" to this
    > > dialog. However, I won't always know if a file by that same name already
    > > exists before the code is run. That means that the dialog will not always
    > > appear. I guess I could use Sendkeys, but that would only work if an
    > > existing file by that same name would always be in that folder. Any idea as
    > > to how to get around this?
    > >
    > > ActiveWorkbook.SaveAs Filename:="C:\filename.txt", FileFormat:=xlText, _
    > > CreateBackup:=False
    > > --
    > >
    > > Thanks in advance!
    > > Sherwood

    >
    >
    >


+ 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