OutputTo - Excel - no promt to overwrite existing file

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

Guest

I am writing a macro that I run with schedular to output a QUERY as an Excel
document. I want this to be automated and not prompt anyone about
overwriting the existing file

Thanks a mil
Elsa
 
I never use macros, since they don't have any error trapping available, so
I'm not sure what happens in a macro if you try to delete a file and it
doesn't exist. Try it, and if it doesn't work, you'll have to switch to VBA.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


"Printing of Range Name References"
 
I know a bit of VB. I even saved the macro as a module, but the outputto
command in VB does not have the option to prevent the prompt
 
I think Doug is suggesting that you delete the file in VBA code each time
before you output the new file, like so:

'Check for existence first
If Dir(strFileName) <> "" Then
Kill strFileName
End If
'... Now output your new Excel file

strFileName should be the fully qualified path name
(drive:\folder\file_name).

"Printing of Range Name References"
 
I'm not sure what happens in a macro if you try to delete a file

You get a file not found exception. But that reminds me of
an old story from a friend: They had converted from a minicomputer
BASIC to a PC BASIC, and one day they got a call from a client:

"When you delete a data set, is it supposed to take a long time?
my computer disk has been active for a long time..."

They had converted from a dialect where "Kill" with no parameters
meant Kill the last file accessed, to a dialect where Kill with
no parameters meant something like Kill *.*

The client had found a rarely exercised section of code, and
the application was in the process of deleting *.* from his disk.

All ended well, and the next day they were couriering out new
copies of the application to remote mining sites all over OZ.

(david)
 
Why when an OutputTo Macro is called from the switchboard, it does not ask to
replace the file, it just does? But if the macro is called from anywhere
else it asks to replace the file.
 
Back
Top