on error

I have this code in my form. It is intended to go through each control and set its font.
Not all controls allow .fontname and use .font.name instead, so the on error lets the code go through each one.

This used to work, but now it doesn't

On Error Resume Next
For Each ctl In form.Controls
  With ctl
    .FontName = myFontName
    .Font.Name = myFontName
    .FontFixed.Name = myFontName
    .FontBold = myFontBold
    .Font.Bold = myFontBold
    .FontItalic = myFontItalic
    .Font.Italic = myFontItalic
  End With
Next

any ideas

I use VB6 SP3
LVL 4
broadbentAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
deightonConnect With a Mentor Commented:
Have you changed to 'break on all errors' in design mode.
0
 
tkuppinenCommented:
Why don't you try to use the typeof syntax?


   If TypeOf MyControl Is CommandButton Then    
     do this

ElseIf TypeOf MyControl Is CheckBox Then
     do this

ElseIf TypeOf MyControl Is TextBox Then
     do this
End If
0
 
tkuppinenCommented:
Just add it inside of the loop
0
 
broadbentAuthor Commented:
Sure, but that requires more work.
The point is that the on error resume did work and should work.
0
 
broadbentAuthor Commented:
Y   e   s    
I   think  I may have done so
Yes I have
I don't know when.

Many thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.