Problem with kill in a form

  • Thread starter Thread starter Joe Cilinceon
  • Start date Start date
J

Joe Cilinceon

I have a routine that prints a series of reports into PDF files. From them
it combines them to a single PDF and saves them under a new name in another
folder for emailing at will. I have a the following lines to delete any old
PDF files in the group folder and I'm having a problem in that it stops the
routine if there are none there. What would the code be to test to see if
there are any PDF files and if so delete them otherwise go on with the
process. The code I'm using is as follows:

Dim SourceFile As String

SourceFile = Application.CurrentProject.path & "\Reports\*.PDF"
Kill SourceFile

I know I could add this code at the end but I don't always want to delete
them right away. These reports are produced every Monday morning.
 
If Dir(SourceFile) <> vbNullString Then
Kill SourceFile
End If

I have a routine that prints a series of reports into PDF files. From them
it combines them to a single PDF and saves them under a new name in another
folder for emailing at will. I have a the following lines to delete any old
PDF files in the group folder and I'm having a problem in that it stops the
routine if there are none there. What would the code be to test to see if
there are any PDF files and if so delete them otherwise go on with the
process. The code I'm using is as follows:

Dim SourceFile As String

SourceFile = Application.CurrentProject.path & "\Reports\*.PDF"
Kill SourceFile

I know I could add this code at the end but I don't always want to delete
them right away. These reports are produced every Monday morning.
_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.
 
Back
Top