deleting files

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a macro that exports a file automatically to a local folder. The file
has to have the same name each time it's run. This works great the first
time but the second time Access/Windows asks me if I want to replace the
file...unfortunately no one is at the PC to answer that question.

Is it possible to either not have that question pop up and it replace the
file automatically OR have Access delete that file when the macro starts up ?
(the file only needs to sit there for 1 minute til another program picks it
up and sends it out...yet the other program cannot delete the file)

Thanks for any suggestions !
Chris
 
Hi Chris - make a simple DOS batch file to delete the file, then add a line
in the macro above when the file is exported and run the DOS batch file using
the RunApp command. Yours - Dika
 
Hi Chris,

You can test for the presence of this file, and, if found, delete it.
Something like this:

Dim strFullPathToFile As String
strFullPathToFile = "FullPathToTheFile"

If Len(Dir(strFullPathToFile)) > 0 Then
Kill strFullPathToFile
End If


In this example, FullPathToTheFile is hard-coded into the procedure. You
could also determine the path dynamically, for example: CurrentProject.Path &
"\FileName", or pass it into a function as a parameter.

Tom Wickerath
Microsoft Access MVP

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________
 
Or
SetWarnings Off
TransferText
SetWarnings On

in a macro - I would however reccomend using code instead of macros.
Flexibility & Error handling being the most important reasons

Pieter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top