+ Reply to Thread
Results 1 to 2 of 2

Overwriting text files

  1. #1
    Orlando Acevedo
    Guest

    Overwriting text files

    I'm writing a macro that opens several workbooks, transforms them and then
    saves them as a text files.
    The problem is that I need the same files overwritten, and when I use the
    line below, I get a message saying that a file with the same name already
    exists and asks if I want to replace it, which means that I can't automate
    the process because I have to click on 'yes' after each file is ready.
    Is there a way to automate this?

    ActiveWorkbook.SaveAs Filename:= strPath & "\" & strFileName(i) & ".txt",
    FileFormat:=xlText

    Thank you.



  2. #2
    sqwawk
    Guest

    Re: Overwriting text files


    Orlando Acevedo wrote:
    > I'm writing a macro that opens several workbooks, transforms them and then
    > saves them as a text files.
    > The problem is that I need the same files overwritten, and when I use the
    > line below, I get a message saying that a file with the same name already
    > exists and asks if I want to replace it, which means that I can't automate
    > the process because I have to click on 'yes' after each file is ready.
    > Is there a way to automate this?
    >
    > ActiveWorkbook.SaveAs Filename:= strPath & "\" & strFileName(i) & ".txt",
    > FileFormat:=xlText
    >
    > Thank you.


    Try turning off the system messages prior to saving the file (and
    turning them on again after)

    Application.DisplayAlerts=False

    ActiveWorkbook.SaveAs Filename:= strPath & "\" & strFileName(i) &
    ".txt",
    FileFormat:=xlText

    Application.DisplayAlerts=True

    HTH
    Neil


+ 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