Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2002
    Location
    NJ
    Posts
    139

    Unanswered: delete a file in excel

    hi,

    I am saving the same workbook mulitple times during the week through code in a macro. Right now it prompts me to the existence of the same workbook and if i want to replace it. That copy is sent to someone else. I would like to delete the existing one and then saving the new one without seeing anything, all in the background in excel when I click on the copy button?

    ActiveWorkbook.SaveAs FileName:="\\USERSTATS\" & Range("C1").Value & ".xls", FileFormat:=xlNormal, _
    Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
    CreateBackup:=False

  2. #2
    Join Date
    Feb 2004
    Posts
    533
    Quote Originally Posted by Alexxx12
    hi,

    I am saving the same workbook mulitple times during the week through code in a macro. Right now it prompts me to the existence of the same workbook and if i want to replace it.

    ActiveWorkbook.SaveAs FileName:="\\USERSTATS\" & Range("C1").Value & ".xls", FileFormat:=xlNormal, _
    Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
    CreateBackup:=False
    Delete the file before saving a copy to the same location.

    strFPath = "testPath"
    If Dir(strFPath) Then Kill strFPath

    ---------------
    Kill Statement Example
    This example uses the Kill statement to delete a file from a disk.

    ' Assume TESTFILE is a file containing some data.
    Kill "TestFile" ' Delete file.

    ' Delete all *.TXT files in current directory.
    Kill "*.TXT"
    ----------------
    Found in Excel VB Help, just type Alt+HH, can also place cursor on a word in the editor and hit the F1 Key.
    Last edited by savbill; 08-17-04 at 22:27.
    ~

    Bill

Posting Permissions

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