Can OutputTo Overlay an existing file?

  • Thread starter Thread starter Brad
  • Start date Start date
B

Brad

I would like to use “OutputTo†to create an output file in HTML format on a
scheduled basis (every night). Is there a way to force OutputTo to overlay
the existing file?

OR

Is there a way to programmatically delete the HTML file right before the
OutputTo command is executed?

Thanks,
 
I would like to use “OutputTo” to create an output file in HTML format on a
scheduled basis (every night). Is there a way to force OutputTo to overlay
the existing file?

OR

Is there a way to programmatically delete the HTML file right before the
OutputTo command is executed?

See the VBA help for the Kill command.

It's brutal but effective.
 
I am a Pacifist so I may struggle with this solution.

You can always use FileCopy before you Kill it... leave something behind to
remember it by, you know (archive it, then delete, then outputto)

hth
--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 
John,

Thanks for the tip.

I am a Pacifist so I may struggle with this solution.

LOL!!!

(I'm not just a pacifist, I'm a vegetarian, so I sympathise). Jack's idea may
be the out.
 
I added the Kill command right before the OutputTo command. After a number
of tests, it appears that the OutputTo is not writing out a new version of
the file (based on file date-time stamp). If I insert a pause statement
after the Kill and before the OutputTo command, a new version of the file is
written out nicely.

I don’t want to use the Pause statement in Production, however, because this
little job is destined to become something that runs in the middle of the
night.

I am guessing that the when the OutputTo command is right after the Kill
command, there is a timing issue with updates sitting in a buffer or cache or
something along these lines.

Perhaps I am missing something. It would be nice if there was a way to
direct the OutputTo to overlay the file, but I have not seen this as an
option.

I have a “work-aroundâ€, but I am curious as to why the Kill right before the
OutputTo does not work for me.

Thanks,
Brad.
 
Brad,

Just a shot in the dark, but try using the FileSystemObject to delete the
file. When you set the variable back to "nothing", it may clear the buffer
and allow the new file to create properly. It's not a brutal as Kill, so may
be better for your pacifist tendencies!

Dim fs as Object
Set fs = CreateObject("Scripting.FileSystemObject")
fs.DeleteFile "C:\mypath\myfile.ext"
Set fs = nothing

Bruce
 
Have you tried putting DoEvents between the two?

Kill Filename
DoEvents
DoCmd.OutputTo...


This should let the system clean up the Kill command before trying to output.

--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 
Back
Top