MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

How to pass a control in a Sub

  Asked By: Dylan    Date: Oct 14    Category: MS Office    Views: 792

I'm stuck in a problem, I'v a sheet where i EMBED a option button. I'v
a separate module where I placed code to pass that control(as Object)
not the VALUE. I'm getting an error "13-Type mismatch"

Pls. Help me !!
Here is the code

Private Sub OptCollapse_Click()
myctrl OptCollapse
End Sub

Public Sub myControl(ByRef otp As OptionButton)
MsgBox otp.Caption
End Sub



3 Answers Found

Answer #1    Answered By: Kawkab Mansour     Answered On: Oct 14

Try just:
Public Sub myControl(otp As Object)

ByRef is the default.

(and change
myctrl OptCollapse
myControl OptCollapse
(a typo I guess))

Answer #2    Answered By: Christina Ramirez     Answered On: Oct 14

Interesting... If it is not too difficult to explain, how is this
different from a simple Call? I am probably missing the true meaning
of said "Option button".

Answer #3    Answered By: Charlie Smith     Answered On: Oct 14

This is nothing but a control  passing. Option Button is nothing but a
ActiveXControl and instead of setting the value/ properties every time for each
control i wated to pass  to thru. a Sub and set the values for that passed

Didn't find what you were looking for? Find more on How to pass a control in a Sub Or get search suggestion and latest updates.