Macro using "Output To" asks to overwrite

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

Guest

I have created a macro that uses the "Output To" action to export 17 reports
in rtf format. Each time a report exports, I am receiving a question of
whether or not to overwrite the existing file. I would like to override
this. I read a question from 2/14/2006 that says it can be done through
Visual Basic but I am not too familiar with writing code in VB. I sent to
the MVP requesting more detail but have not gotten a response.

Can someone please shine some more light on original response? It says I
need to create "a public function in a regular module, and this function
would have a Kill action in it. You call the function using the RunCode
action in the macro."
 
AccessIM,

As far as I know, it is not possible to override this confirmation
prompt via a macro, so the idea of using a VBA procedure instead of a
macro here is advisable. I don't see the point of writing it into a
standard module and then running it via a RunCode macro... why not just
write it straight into the event property where you would normally
assign the macro? The skeleton of the code to do this would be a bit
like this...

Dim OutputFile as String
OutputFile = "C:\YourFolder\YourFile.rtf"
If Len(Dir(OutputFile)) Then
Kill OutputFile
End if
DoCmd.OutputTo acOutputReport, "YourReport", "RichTextFormat(*.rtf)",
OutputFile
 
Back
Top