Re: 'OutPut To' Excel without prompt to overwrite



You would use a public function (put it in a regular module that has a name
different from the function's name) that loops through the .rtf files in a
folder and then deletes them.

Public Function DeleteMyRTFFiles()
Dim strFile As String
Const strPath As String = "C:\MyFolder\"
strFile = Dir(strPath & "*.rtf")
Do While strFile <> ""
Kill strPath & strFile
strFile = Dir()
Loop
End Function


You then call this function from a macro using the RunCode action.
--

Ken Snell
<MS ACCESS MVP>




"AccessIM" <AccessIM@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:CE0D0259-53B4-42BC-B5C1-C94F65183B7A@xxxxxxxxxxxxxxxx
This is exactly what I need but I am not too familiar with writing code in
Visual Basic. Could you please explain in a little more detail? I need
to
delete 17 rtf files before running the OutputTo in the macro. I do not
understand the second paragraph of your response below but I know that's
what
I need to do.

"Ken Snell (MVP)" wrote:

You cannot do this directly in a macro, but you can do it in VBA code
(which
could be in a function that you call from the macro). There is a Kill
method
in VBA that will delete a file. Help file contains information about this
Kill method.

You would create a public function in a regular module, and this function
would have the Kill action in it. You call the function using the RunCode
action in the macro.

--

Ken Snell
<MS ACCESS MVP>

"Paul Dennis" <PaulDennis@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:8BEA1F06-F4BA-4F5E-B5E2-3894776F9330@xxxxxxxxxxxxxxxx
I have a macro that outputs the results of a query to Excel, however if
the
file already exists it prompts to overwrite it - Can I get around this?

I assumed that if I called the Macro from the Main Switchboard form
which
is
auto opened when entering the db I would'nt have this problem but it
makes
no
difference?





.



Relevant Pages

  • Re: Delete Excel Spreadsheet from Access Macro
    ... You go to the modules tab in Access (if Access 2000 or later it will be on ... where you put in your kill statement. ... Kill ("K:\Petro\Fuel Daily Report Files\Carrier Policing Report.xls") ... Now save macro. ...
    (microsoft.public.access.macros)
  • Re: Halt screen startling inexperienced users
    ... >place of the SetValue action in your macro, ... RunCode action (we'll ... >Public Function MakeFormInvisible() ... >> I checked my references in VBA again. ...
    (microsoft.public.access.macros)
  • Re: Macro error
    ... which gave same type of error message in ACCESS ... workaround is to use VBA code to run that particular macro action. ... Public Function MakeFormInvisible() ... >> <MS ACCESS MVP> ...
    (microsoft.public.access.macros)
  • RE: Macro Suddenly Stopped Working
    ... Was a protected worksheet the problem? ... The macro suddenly stopped working and the user that created it is no ... Sub NormalizeData() ... Public Function CellFunction ...
    (microsoft.public.excel.programming)
  • RE: Macro Suddenly Stopped Working
    ... macro tries to paste to a locked cell you will get a runtime error. ... The macro suddenly stopped working and the user that created it is no ... Sub NormalizeData() ... Public Function CellFunction ...
    (microsoft.public.excel.programming)