chadzilla
10-18-2007, 04:36 AM
Hello all,
I have a macro that exports a table to an excel file using the OutputTo option in the macro builder. The macro works fine, but every time I run it, I get a prompt that the file already exists, and it asks if I want to over write the existing file. Is there a way to get rid of the prompt and just automatically over write the file?
Thanks for any help.
Zigzag
10-18-2007, 04:48 AM
Hi,
This is a snip of code pinched from a previous thread posted by Bob Larsen.
If Dir(strFileNameAndPath)<> "" Then
Kill(strFileNameAndPath)
DoCmd.OutputTo...
Else
DoCmd.OutputTo...
End If
Do a search of this forum for "KILL" and you will find other examples.
Garry
Dennisk
10-18-2007, 05:56 AM
or you could set the warnings off but make sure you turn them back on again
search help for DoCMD.Setwarnings
Zigzag
10-18-2007, 06:24 AM
I dont think that "docmd.setwarnings" will switch off the warning if thay are being generated outside of Access as I think is the case here.
Garry
Dennisk
10-19-2007, 04:33 AM
the warnings are being generated by Access.
chadzilla
10-19-2007, 04:40 AM
Thanks for the info. I'll be trying this today, and I will let you guys know.
Zigzag
10-19-2007, 04:48 AM
http://www.access-programmers.co.uk/forums/showthread.php?t=134418&highlight=kill
Garry
Kinger43
10-19-2007, 05:56 AM
I agree with Garry, I think this particular warning is being generated by Windows itself and not Access. If this is the case then SetWarnings will not stop this warning from happening. boblarson has a good example of how to stop this warning.