Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Output to command ques 1

Status
Not open for further replies.

atadbitslow

Programmer
Feb 26, 2001
301
US
Is there a switch or another way to automatically overwrite a file if it already exists? I am using the output to command in a macro to output a report to Excel format with a given name, but I don't want the user to have to answer the overwrite questions??

Thanks!
 
Maybe the simplest way would be to write a VBA procedure to delete the file if it exists:
Code:
    Public Sub DeleteFile(FilePath As String)
        On Error Resume Next
        Kill FilePath
    End Sub
Then just insert a RunCode action with the Function Name set to: DeleteFile("C:\My Documents\My File.ext") Rick Sprague
 
Thanks Rick--I finally got around to doing this, but I got an error that said "The expression you entered has a function name that Access can't find."

I put the function under modules--is that correct? Should it be a public function instead of sub?

Thanks!
 
You cat set the warning off, execute and set the warning on again. John Fill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top