I've read the thread where you can find the code for this. However, how can I implement it into a user form in Excel?
Printable View
I've read the thread where you can find the code for this. However, how can I implement it into a user form in Excel?
Yes, I wrote the code located here to disable the 'x' button on a userform.
Thanks a lot. I've been trying to run the code, however I can't still figure how to make it work... I have two questions.
Where do I insert:
VB Code:
Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, _ ByVal wFlags As Long) As Long Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, _ ByVal lpWindowName As String) As Long Private Const MF_BYPOSITION = &H400&
And, what does Option Explicit mean?
Option Explicit means you have to predeclare all variables before using them (which is a very, VERY good thing)Quote:
Originally Posted by Fonty
Download my attached workbook example to see where it all goes.
I'm sorry... I didn't see the attachement. However, when I try to change the name of the user form, called UserForm1 in your example, it doesn't show anything and keeps running the routine:
VB Code:
lHwnd = FindWindow("ThunderDFrame", "UserForm1")
I runs now... Thank you for this code, truly.
No prob. ;) Glad its working for you now. :)
When I first ran it for a userform containing a combobox which is filled with a for, it showed and error on the index of the for. And it worked fine when I inserted at the beginning Dim i As Integer. Why does this happen?
The same happened for a MsgBox called message. It didn't work until I inserted Dim message.
What was the error it showed?Quote:
Originally Posted by Fonty
Variable not defined
That is exactly what I figured, and that will occur if you have Option Explicit on and attempt to use a variable without first declaring it.Quote:
Originally Posted by Fonty
Before doing the Dim neither i or Message had been declared, so it didn't know what to do with them.