Share via

macro replace existing file

Anonymous
2012-02-16T20:02:43+00:00

i am trying to use macro to run all 10 reports. But, i am stuck with the replaceing existing file. How can i make to default to "Yes".

here is the maco

Action: OpenReport

             Argument: Report name: PU

                               View: Report

Action: OutputTo

             Argument: Object Type: Report

                               Object Name: PU

                               Output Format: PDF

                                Output File: C:\User....

After the bring up the report and a popup windows "The file "C........" already exists. Do you want to replace the existing file? Yes, No.

Can I make this default to Yes everytime?

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2012-03-05T17:56:52+00:00

I'm not sure what you're asking here, Schoa: you want to kill the file but you don't want to use kill???

I wonder if the best solution might be to run this report from a script in Windows Scheduler, which would delete the file and then call Access with an /x macroname runtime command switch to run the report.

I have never heard of "taskkill" and I have no idea what difference Server 2008 would make; you might want to ask this in a Server forum.

Was this answer helpful?

0 comments No comments

Answer accepted by question author

Anonymous
2012-02-16T21:40:13+00:00

If you were using VBA you could use

KILL C:\User...

before running the OutputTo action. However, I'm pretty sure that KILL is one of the "unsafe" operations that caused Microsoft to start emphasizing macros over code! After all, if you can Kill this report output file, what's to stop the program from Kill-ing the master copy of the annual report, or any other file?

Was this answer helpful?

0 comments No comments

4 additional answers

Sort by: Most helpful
  1. Anonymous
    2012-03-05T13:44:45+00:00

    Yes, there are another files. That's why I really don't want to use KILL. Do you think the taskkill doesn work it is because of windows server 2008?

    I believe it works on Xp or other OS.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2012-02-16T21:27:29+00:00

    I tried the put SetWarnings action and set Warnings On to No. But it still pop up the windwos asking The file "C........" already exists. Do you want to replace the existing file? Yes/No

    Was this answer helpful?

    0 comments No comments
  3. HansV 462.6K Reputation points
    2012-02-16T20:41:40+00:00

    Open the macro in design view.

    Make sure that the button "Show All Actions" in the Design tab of the ribbon is highlighted *)

    Select the SetWarnings action and set Warnings On to No.

    Move this action up to the beginning of the macro.

    Near the end, add a SetWarnings action and set Warnings On to Yes.

    *) The database must have been saved in a Trusted Location, otherwise Show All Actions is disabled.

    Was this answer helpful?

    0 comments No comments