UserForm X disabling

renderman7

New Member
Joined
Oct 27, 2011
Messages
10
Hi all,

I am trying to disable the X on some userforms and have the following code:

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)

If CloseMode = 0 Then Cancel = True

End Sub

But when I run the code, it tells me "user-defined type no defined"

Am I placing the code in the correct spot, or am I missing something else?
Thanks
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Where is the code located?
 
Upvote 0
Do you mean that it is in the Userform code module?
 
Upvote 0
Hi,

Looks like error of another part of your code.
Try these steps of debugging:

1. Use setting:
VBE - Tools - Options - General - Break in Class Module - OK

2. Let the debugger check your source code:
VBE - Debug – Compile VBAProject

Incorrect chain of the code will be selected by debugger with a warning message.
Fix that part of the code and repeat step 2 till success compiling
 
Last edited:
Upvote 0
What line of code, or what keyword, is highlighted when you see the error.

There's nothing wrong with the code you've posted.
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,906
Members
452,366
Latest member
TePunaBloke

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