YellowLabPro
09-21-2007, 09:58 AM
In my block of code below, if the Workbook is not present in the directory, I would have expected it to error. But it does not, it continues to process it.
I have put a check into the block of code to see if the file is present. But I think there are few things wrong w/ my approach.
How can I put a Debug.Print in there to see if there is an error ocurring and where would I place this to see?
Original code:
err.Clear
On Error Resume Next
Set wsSource = Workbooks(wbn).Sheets(wsn)
iStatus = err
If iStatus Then
Workbooks.Open wPath & wbn
On Error GoTo 0
Sheets(wsn).Activate
Else
Workbooks(wbn).Sheets(wsn).Activate
End If
New Code w/ error checking:
err.Clear
On Error Resume Next
Set wsSource = Workbooks(wbn).Sheets(wsn)
If IsNull(wPath & wbn) Then
MsgBox wbn & "Is Not Present in the Directory" + vbCritical
Exit Sub
End If
iStatus = err
If iStatus Then
Workbooks.Open wPath & wbn
On Error GoTo 0
Sheets(wsn).Activate
Else
Workbooks(wbn).Sheets(wsn).Activate
End If
I have put a check into the block of code to see if the file is present. But I think there are few things wrong w/ my approach.
How can I put a Debug.Print in there to see if there is an error ocurring and where would I place this to see?
Original code:
err.Clear
On Error Resume Next
Set wsSource = Workbooks(wbn).Sheets(wsn)
iStatus = err
If iStatus Then
Workbooks.Open wPath & wbn
On Error GoTo 0
Sheets(wsn).Activate
Else
Workbooks(wbn).Sheets(wsn).Activate
End If
New Code w/ error checking:
err.Clear
On Error Resume Next
Set wsSource = Workbooks(wbn).Sheets(wsn)
If IsNull(wPath & wbn) Then
MsgBox wbn & "Is Not Present in the Directory" + vbCritical
Exit Sub
End If
iStatus = err
If iStatus Then
Workbooks.Open wPath & wbn
On Error GoTo 0
Sheets(wsn).Activate
Else
Workbooks(wbn).Sheets(wsn).Activate
End If