How to open UserForm code by VBA?

Sbirro Cornuto

Board Regular
Joined
Mar 18, 2002
Messages
93
'Sup?
How can I open the UserForm code module by macro. Like when I use VBA to open some regular macro, you know with 'Application.Goto Reference:="the name of the Sub"'. This doesn't work if the Sub is in the UserForm. How should I name the Reference? Any ideas?
 
On 2002-03-22 01:49, Dave Hawley wrote:
Hey! My shot in the dark wasn't that far off then!

Go Ivan!

Actually it was your shot in the dark that
got me thinkin along this line where as I
was on another tack with App.Goto Ref etc.

Thanks Dave

Ivan
 
Upvote 0

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
U wont to know what is written in Userform1?
Please try This!

Sub test()
With ThisWorkbook.VBProject.VBComponents("UserForm1").CodeModule
MsgBox .Lines(1, .CountOfLines)
End With
End Sub

Sub test2()
ThisWorkbook.VBProject.VBComponents("UserForm1").CodeModule.CodePane.Show
End Sub
 
Upvote 0
Thanks dudes, you're awesome! I knew I could trust you on this one.

I actually do know what's written in the UserForm, I'm just working on this "Advanced VBE" type of thing and couldn't get pass that UserForm thing. Well now I can, so thanks again!
 
Upvote 0
hi,
i tried to use first one code sub test().
it worked but i think it only showing till 1 page max.
is there any way to print full code in pdf or in notepad or in word?
will this work even if userform1 is password protected?
thanks in advance.
Abhisekh

U wont to know what is written in Userform1?
Please try This!

Sub test()
With ThisWorkbook.VBProject.VBComponents("UserForm1").CodeModule
MsgBox .Lines(1, .CountOfLines)
End With
End Sub

Sub test2()
ThisWorkbook.VBProject.VBComponents("UserForm1").CodeModule.CodePane.Show
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,212,936
Messages
6,110,764
Members
448,297
Latest member
cocolasticot50

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