|
-
Jun 15th, 2006, 10:26 AM
#1
Thread Starter
Addicted Member
Resolved[Removing Close Button]
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?
Last edited by Fonty; Jun 15th, 2006 at 10:53 AM.
-
Jun 15th, 2006, 10:28 AM
#2
Re: Removing Close Button
Yes, I wrote the code located here to disable the 'x' button on a userform.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 15th, 2006, 10:37 AM
#3
Thread Starter
Addicted Member
Re: Removing Close Button
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?
-
Jun 15th, 2006, 10:39 AM
#4
Re: Removing Close Button
 Originally Posted by Fonty
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)
-
Jun 15th, 2006, 10:48 AM
#5
Re: Removing Close Button
Download my attached workbook example to see where it all goes.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 15th, 2006, 10:50 AM
#6
Thread Starter
Addicted Member
Re: Removing Close Button
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")
-
Jun 15th, 2006, 10:52 AM
#7
Thread Starter
Addicted Member
Re: Removing Close Button
I runs now... Thank you for this code, truly.
-
Jun 15th, 2006, 11:08 AM
#8
Re: Resolved[Removing Close Button]
No prob. Glad its working for you now.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 15th, 2006, 11:16 AM
#9
Thread Starter
Addicted Member
Re: Resolved[Removing Close Button]
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.
-
Jun 15th, 2006, 11:18 AM
#10
Re: Resolved[Removing Close Button]
 Originally Posted by Fonty
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?
-
Jun 15th, 2006, 11:20 AM
#11
Thread Starter
Addicted Member
Re: Resolved[Removing Close Button]
-
Jun 15th, 2006, 11:31 AM
#12
Re: Resolved[Removing Close Button]
 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.
Before doing the Dim neither i or Message had been declared, so it didn't know what to do with them.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|