ignore error message and continue if path not found in VBA?
Posted on 2003-10-28
I have the following piece of code that looks for various files, attaches them and then emails them. Problem is that some files are only there occaisionally (ie not every week), so when it can't find the path (varAttach(x - 1) = Email("Path") & " " & Email("Account name") & " " & Email("Account Number" & x) & " September 2003.xls") i get an error message and have to start again. I need a piece of code that will skip a path it can't find and move on to the next path without bringing up an error message.
PS any answers as simple as possible I'm not very good at VBA!
Many thanks in advance.
Private Sub Command0_Click()
Dim varpeeps(10) As Variant
Dim varAttach(10) As Variant
Dim xlapp As Object
Dim dbAddress As Database
Dim Email As Recordset
Dim x As Integer
Dim DateBox As String
Set dbAddress = CurrentDb
Set Email = dbAddress.OpenRecordset("Email Addresses")
DateBox = Forms![Form1]!DateBox
Do Until Email.EOF
For x = 1 To 7
If IsNull(Email("Email Address " & x)) = False Then
varpeeps(x - 1) = Email("Email Address " & x)
x = 0
For x = 1 To 8
If IsNull(Email("Account Number" & x)) = False Then
varAttach(x - 1) = Email("Path") & " " & Email("Account name") & " " & Email("Account Number" & x) & " September 2003.xls"
x = 0