SetWarnings

S

Susie

I have written about this and gotten some very good
suggestions, but still having problems. I have a macro
that runs approx 150 reports. I save these reports to a
folder that is uploaded to our intranet daily. When I run
the macro, I get a dialog box asking if I want to replace
the file. I always want to replace the file. I have
tried to use the action "SetWarnings" in the macro to no
avail. I have also gone into Tools, Options and set the
Confirm Action queries in the Edit/Find tab. Neither of
these options have worked. Does anyone have any other
suggestions for me? I would really like to find something
rather than click OK for 150 reports. Thanks for any help
you can give me.
 
G

George Nicholson

AFAIK, SetWarnings only applies to warnings based on changes within Access
objects. File saving is Windows territory, outside of Access sphere of
influence.

In VBA, you can delete the old file before you save the new one:
Kill "c:/KillTest.txt"
The Kill statement doesn't seem to ask for confirmation before deleting.
Once the file is gone, you don't need to worry about the "Replace?" warning.

Kill will generate errors if 1) the file doesn't exist or 2) is open.
Include error handling as you see fit.
 
D

Douglas J. Steele

You may have to switch from using macros to using VBA. In VBA, you can check
whether the file already exists, and delete it if it doesn't:

dim strFile As String

strFile = "C:\Data Files\MyFile.txt"

If Len(Dir(strFile)) > 0 Then
Kill strFile
End If
 
A

Adam Kenney [MSFT]

You should also be able to use the Macro "SendKeys" command to send
"{Enter}" (without the quotes) to the application. SendKeys should go
directly before the command that generates the dialog box, with Wait set to
No.

Adam Kenney
Microsoft Software Test Engineer
 
Top