disable option button on user form

J

JH

I have a large number of workbooks with an user form, the user form shows up
when the workbook is open. I am trying to disable one of the option buttons
on the user form. How can I do it programmatically?
Thanks!

JH
 
S

Susan

if you want it disabled always, you can do that in the userform
properties.

if you want it disabled due to a certain condition when the userform
opens, you can do it programatically in the userform_initialize sub

if xxxxxxxx then
optionbutton1.enabled=false
else
optionbutton1.enabled=true
end if

where "xxxxxxx" is your condition.
hope that helps.
:)
susan
 
J

JH

Hi,
I added this line to my macro. " frmMenu.opt1.Enabled = false", I got
an error message, "Object required". The macro is located in another
workbook. I am intended to use this macro to loop through all the workbooks
that needed changes.
The code is as follow:

................................
fname = Dir(pname, vbNormal)
Do
If Len(fname) < 28 Then

Workbooks.Open FileName:=pname & fname, UpdateLinks:=False
frmMenu.opt1.Enabled = False
Workbooks(fname).Close saveChanges:=True
End If
fname = Dir() 'get another filename
Loop Until fname = ""
 
S

Susan

since the userform is in another workbook, you need to qualilfy your
workbooks (which you're already doing).

try something like

Workbooks(fname).frmMenu.opt1.Enabled = false

then it knows WHERE to find frmMenu.
hope it helps.
:)
susan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top