PDA

Click to See Complete Forum and Search --> : Resolved[Removing Close Button]


Fonty
Jun 15th, 2006, 10:26 AM
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?

RobDog888
Jun 15th, 2006, 10:28 AM
Yes, I wrote the code located here (http://vbforums.com/showthread.php?t=363931) to disable the 'x' button on a userform.

Fonty
Jun 15th, 2006, 10:37 AM
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:

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?

Hack
Jun 15th, 2006, 10:39 AM
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)

RobDog888
Jun 15th, 2006, 10:48 AM
Download my attached workbook example to see where it all goes.

Fonty
Jun 15th, 2006, 10:50 AM
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:

lHwnd = FindWindow("ThunderDFrame", "UserForm1")

Fonty
Jun 15th, 2006, 10:52 AM
I runs now... Thank you for this code, truly.

RobDog888
Jun 15th, 2006, 11:08 AM
No prob. ;) Glad its working for you now. :)

Fonty
Jun 15th, 2006, 11:16 AM
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.

Hack
Jun 15th, 2006, 11:18 AM
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?

Fonty
Jun 15th, 2006, 11:20 AM
Variable not defined

Hack
Jun 15th, 2006, 11:31 AM
Variable not definedThat 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.

Before doing the Dim neither i or Message had been declared, so it didn't know what to do with them.