?
Solved

Trap and continue in Loop..

Posted on 2002-04-05
9
Medium Priority
?
166 Views
Last Modified: 2012-05-04
I have a routine that thumbnails an entire directory.
The problem is animated gifs or unsupported file types.
I cannot get this loop to continue if it bombs because of an err.number 481....
There has to be a way to increment and continue onto the next file...I have tried everything I can think of...

Public Sub SaveWholeFolder(sType As String)
For i& = 0 To frmDemo.List1.ListCount - 1
  fName$ = frmDemo.List1.List(i&)
  'On Error do what?
  frmDemo.picHidden.Picture = LoadPicture(fName$)
  Call StretchPic(frmDemo.picHidden, frmDemo.picMain)
  frmDemo.Caption = i&
  DoEvents
  x$ = Mid(fName$, InStrRev(fName$, "\") + 1)
  xx$ = Mid(x$, 1, InStr(x$, "."))
  xx$ = xx$ & sType
  Call SavePicture(frmDemo.picMain, App.path & "\Thumbnails\" & xx$)
Next i&

End Sub

Thanks
0
Comment
Question by:Form_Glow
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 5

Expert Comment

by:rkot2000
ID: 6920997
on error resume next


atfer the line with possible error

if err.numnber <>0 then
  log this error
  err.clear
end if
0
 
LVL 18

Expert Comment

by:bobbit31
ID: 6920998
wouldn't something like this work?

Public Sub SaveWholeFolder(sType As String)
For i& = 0 To frmDemo.List1.ListCount - 1
 fName$ = frmDemo.List1.List(i&)
 On Error GoTo SkipMe
 frmDemo.picHidden.Picture = LoadPicture(fName$)
 Call StretchPic(frmDemo.picHidden, frmDemo.picMain)
 frmDemo.Caption = i&
 DoEvents
 x$ = Mid(fName$, InStrRev(fName$, "\") + 1)
 xx$ = Mid(x$, 1, InStr(x$, "."))
 xx$ = xx$ & sType
 Call SavePicture(frmDemo.picMain, App.path & "\Thumbnails\" & xx$)

 SkipMe:

Next i&

End Sub

0
 
LVL 5

Accepted Solution

by:
rkot2000 earned 400 total points
ID: 6921045
full solution :

Public Sub SaveWholeFolder(sType As String)
On Error resume next
For i& = 0 To frmDemo.List1.ListCount - 1
 fName$ = frmDemo.List1.List(i&)
 frmDemo.picHidden.Picture = LoadPicture(fName$)
     if err.number = 0 then
          Call StretchPic(frmDemo.picHidden, frmDemo.picMain)
           frmDemo.Caption = i&
           DoEvents
           x$ = Mid(fName$, InStrRev(fName$, "\") + 1)
           xx$ = Mid(x$, 1, InStr(x$, "."))
           xx$ = xx$ & sType
           Call SavePicture(frmDemo.picMain, App.path & "\Thumbnails\" & xx$)
     else
          err.clear
     end if    
Next i&

End Sub
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:Form_Glow
ID: 6921076
Still bombs out at the first ani...tried all 3 solutions.........
0
 
LVL 5

Expert Comment

by:rkot2000
ID: 6921119
check you tools-options-general tab - error trapping should be set to break in class module
0
 
LVL 15

Expert Comment

by:ameba
ID: 6921125
or "Break on Unhandled Errors"
0
 
LVL 1

Author Comment

by:Form_Glow
ID: 6921163
The problem appears to be (always a file) in temp internet folder....Searching the drive the file does not exist....but my FindFiles routine is finding these strange "fake" gifs....that will always make it by the error trap...and lock the app.
0
 
LVL 17
ID: 6921185
can you call out to another routine?

Private Sub Command1_Click()
Dim ix As Integer

For ix = 1 To 100
dostuff ix
Next ix

End Sub



Private Sub dostuff(ix As Integer)
On Error GoTo handler:
'simulate error condition
If ix = 50 Then Err.Raise vbObjectError + 2002, "me", "test"
'the call that would actually generate the error
List1.AddItem ix
Exit Function
handler:
End Function
0
 
LVL 15

Expert Comment

by:ameba
ID: 6921829
Ah, yes, that error...
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month16 days, 19 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question