OutputTo - Excel - no promt to overwrite existing file

  • Thread starter Printing of Range Name References
  • Start date
P

Printing of Range Name References

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
 
D

Douglas J Steele

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"
 
P

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
 
R

Ron Hinds

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"
 
D

david epsom dot com dot au

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)
 
P

pams_cf

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.
 

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

Top