LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Adding OptionButtons to array error 91

Have the following code to add OptionButtons to a control array:

A class called OptionButtonClass:

Option Explicit
Public WithEvents objOptionButton As MSForms.OptionButton

Private Sub objOptionButton_MouseDown(ByVal Button As Integer, _
ByVal Shift As Integer, _
ByVal X As Single, _
ByVal Y As Single)

Dim lContextHelpID As Long

If Button = 2 Then
On Error Resume Next
lContextHelpID = objOptionButton.HelpContextID
On Error GoTo 0
If lContextHelpID 0 Then
ShowHelp bWebHelp, lContextHelpID
End If
End If

End Sub

In a normal module:

Public OptionButtons(24) As OptionButtonClass

Sub AddOptionButtonsToArray(oForm As UserForm, lStart)

Dim ctl As MSForms.Control
Dim i As Long

i = lStart

For Each ctl In oForm.Controls
If TypeName(ctl) = "OptionButton" Then
OptionButtons(i).objOptionButton = ctl
i = i + 1
End If
Next

End Sub

The above Sub is called like this:

AddOptionButtonsToArray MainForm, 0

I get an error 91: Object variable or with block not set when initializing
the form MainForm
and the line where the problem is is:
OptionButtons(i).objOptionButton = ctl

No idea why this falls over as exactly the same principle works fine with
checkboxes and labels.
Any advice with this greatly appreciated.


RBS




 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Choosing Only One Of Three OptionButtons Minitman[_4_] Excel Programming 2 August 18th 05 12:59 PM
Array of OptionButtons ? MWE[_37_] Excel Programming 3 April 21st 04 03:16 AM
OptionButtons Paul Excel Programming 4 December 4th 03 04:12 PM
Add OptionButtons in Excel Andrew Lenczycki Excel Programming 0 July 30th 03 02:34 PM
optionbuttons Phil Perry Excel Programming 1 July 10th 03 09:13 PM


All times are GMT +1. The time now is 11:33 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"