Modeless userform with Initialize event fails

shg

MrExcel MVP
Joined
May 7, 2008
Messages
21,836
Office Version
  1. 2010
Platform
  1. Windows
I have a modeless userform that works great (I use the default instance):

VBA Code:
frmHighlight.Show vbModeless

I just just added an initialize event:

VBA Code:
Private Sub UserForm_Initialize()
  Set oCol = New Collection

  oCol.Add Array(vbNullString, False, vbBlack)  ' dummy for sorting
  With Me.txtInp
    oCol.Add Array(.Value, .Font.Bold, .Font.Color)
  End With
End Sub

oCol is a collection object declared at the top of the module; it's purpose is to keep a history of form states that a spin button can ratchet through.

Now I get a runtime error 438 on the .Show line: "Object doesn't support this property or method". If I comment out the initialize event, it works fine again.

Anyone see the error of my ways?
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Just guessing: change .font.bold into .font.style
 
  • Like
Reactions: shg
Upvote 0
What is txtInp?
If it's a textbox there is no .Font.Color property, it should be .ForeColor
 
  • Like
Reactions: shg
Upvote 0
@GWteB: Thanks for that. Font.Bold is used elsewhere without problems, and shows up in IntelliSense.

@Fluff: BINGO! Brain cramp, thank you.
 
Upvote 0
It has to be ForeColor. .Font.Color does not exist .Font.Bold does.

- edit-
 
Upvote 0
Glad we could help & thanks for the feedback
 
Upvote 0
Perfect now, thank you both again.
 
Upvote 0

Forum statistics

Threads
1,215,059
Messages
6,122,917
Members
449,093
Latest member
dbomb1414

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top