[VBA] Removing the red cross from a UserForm

Last update on December 6, 2008 09:23 AM by netty5
Published by netty5

[VBA] Removing the red cross from a UserForm






It may be needed that the possibility for exiting a userform until all entries have been entered is prohibited, but there is still the red cross which allows the user to exit.

Use the following code to remove the cross.

In the declaration part of a UF

'to remove the cross in a user form
 Declare Function GetWindowLongA Lib "user32" _
(ByVal hwnd As Long, ByVal nIndex As Long) As Long

 Declare Function SetWindowLongA Lib "user32" _
(ByVal hwnd As Long, ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long

 Declare Function FindWindowA Lib "user32" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long

In the initialization of the UF

Private Sub UserForm_Initialize()
Dim hwnd As Long
    hwnd = FindWindowA("Thunder" & IIf(Application.Version Like "8*", "X", "D") _
    & "Frame", Me.Caption)
    SetWindowLongA hwnd, -16, GetWindowLongA
Best answers for « Removing the red cross from a UserForm » in :
[MSN Messenger] Delete contacts on the red list Show[MSN Messenger] Delete contacts on the red list Procedure Notes Windows Live Messenger does not allow you to remove someone from the red list. Indeed, an undesired contacts will still appear your contact list, the "delete" box is...
Remove Applications on your iPhone ShowRemove Applications on your iPhone To remove applications on the iPhone, follow this procedure: Press the icon of the application side for 2 seconds Press again on the cross (like "Close" for Windows) The application will be removed.
Removing Alpha Antivirus scam ShowRemoving Alpha Antivirus scam Issue Uninstall/Remove Alpha Antivirus Note Issue Be careful of Alpha Antivirus, this is a fake antivirus (scam), which main purpose is to steal money and isn’t reliable at all! Alpha Antivirus, at start...
Download MBSA ShowMBSA stands for Microsoft Baseline Security Analyzer. This software allows you to analyze your operating system: Windows NT/2000/XP/Server 2003. Once MBSA is launched thrown, you will see: - The red cross indicates that critical updates are...
Download Photomizer ShowPhotomizer is a tool that gives you the ease of resizing, rotating, editing images quickly. The application provides the ability not also to remove red eyes from images but to increase contrast, re-adjust tonality of images and more. Features It...
Download Remove Empty Directories ShowRemove Empty Directories or RED is a free software intended to abolish the empty files. RED searches and abolishes the empty files by showing by a tree-like aspect the way of access to the file. You can create certain rules to be able to keep a...
Utilities for Removing Common Viruses and Worms ShowWhat is a virus removal tool? A virus removal tool is a small executable file for cleaning a machine which has been infected by a particular virus. Each removal tool is therefore uniquely capable of eradicating a particular kind of virus, or a...