If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > delete a file in excel

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-17-04, 16:52
Alexxx12 Alexxx12 is offline
Registered User
 
Join Date: Sep 2002
Location: NJ
Posts: 139
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
Reply With Quote
  #2 (permalink)  
Old 08-17-04, 21:21
savbill savbill is offline
Registered User
 
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.
__________________
~

Bill

Last edited by savbill; 08-17-04 at 21:27.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On