rvisser1988
Gebruiker
- Lid geworden
- 24 aug 2011
- Berichten
- 31
Besten,
Ik ben nu al een poosje bezig om mijn userform netjes op de taakbals te krijgen, zodat ik Excel mooi kan sluiten.
Na veel zoeken is deze code om dit enkel voor het hoofduserform toe te passen deze (uiteraard niet mijn eigen geschreven code:d):
Nu krijg ik alleen telkens de foutmelding: Fout 400 tijdens de uitvoering. Het formulier wordt al weergegeven, en kan niet modaal worden weergegeven.
Ik heb al dagen zitten zoeken wat precies modaal is en hoe ik het uit deze code kan krijgen. Ik heb ook al tal zal andere codes geprobeerd, maar die geven over het algemeen allemaal foutmeldingen in het hoofdscript van de userform.
Ik hoop dat het op te lossen is en hoor graag jullie reacties.
Mijn dank is in ieder geval groot!!!
Ik ben nu al een poosje bezig om mijn userform netjes op de taakbals te krijgen, zodat ik Excel mooi kan sluiten.
Na veel zoeken is deze code om dit enkel voor het hoofduserform toe te passen deze (uiteraard niet mijn eigen geschreven code:d):
Code:
'Windows API calls
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" ( _
ByVal hWnd As Long, _
ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" ( _
ByVal hWnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Private Declare Function ShowWindow Lib "user32" ( _
ByVal hWnd As Long, _
ByVal nCmdShow As Long) As Long
Private Declare Function EnableWindow Lib "user32" ( _
ByVal hWnd As Long, _
ByVal fEnable As Long) As Long
Private Declare Function DrawMenuBar Lib "user32" ( _
ByVal hWnd As Long) As Long
Private Declare Function SetFocus Lib "user32" ( _
ByVal hWnd As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( _
ByVal hWnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Integer, _
ByVal lParam As Long) As Long
Private Declare Function LockWindowUpdate Lib "user32" ( _
ByVal hWndLock As Long) As Long
'Window styles
Private Const GWL_STYLE As Long = (-16) 'The offset of a window's style
Private Const GWL_EXSTYLE As Long = (-20) 'The offset of a window's extended style
Private Const WS_CAPTION As Long = &HC00000 'Style to add a titlebar
Private Const WS_SYSMENU As Long = &H80000 'Style to add a system menu
Private Const WS_MINIMIZEBOX As Long = &H20000 'Style to add a Minimize box on the title bar
Private Const WS_MAXIMIZEBOX As Long = &H10000 'Style to add a Maximize box to the title bar
Private Const WS_EX_APPWINDOW As Long = &H40000 'Application Window: shown on taskbar
Private Const WS_EX_TOOLWINDOW As Long = &H80 'Tool Window: small titlebar
'Hide or show a window
Private Const SW_HIDE As Long = 0
Private Const SW_SHOW As Long = 5
'Windows messages
Private Const WM_SETICON = &H80
Private hWnd As Long
Public Sub Userform_Initialize()
'Get the userform's window handle
If Val(Application.Version) < 9 Then
hWnd = FindWindow("ThunderXFrame", Me.Caption) 'XL97
Else
hWnd = FindWindow("ThunderDFrame", Me.Caption) 'XL2000+
End If
SendMessage hWnd, WM_SETICON, True, 0
SendMessage hWnd, WM_SETICON, False, 0
LockWindowUpdate hWnd
EnableWindow FindWindow("XLMAIN", Application.Caption), True
ShowWindow hWnd, SW_HIDE 'Hide the form
lStyle = GetWindowLong(hWnd, GWL_STYLE) Or WS_CAPTION Or WS_SYSMENU Or WS_MINIMIZEBOX Or WS_MAXIMIZEBOX
SetWindowLong hWnd, GWL_STYLE, lStyle
lStyle = GetWindowLong(hWnd, GWL_EXSTYLE) Or WS_EX_APPWINDOW And Not WS_EX_TOOLWINDOW
SetWindowLong hWnd, GWL_EXSTYLE, lStyle
DrawMenuBar hWnd
SetFocus hWnd
ShowWindow hWnd, SW_SHOW 'Reshow the userform
LockWindowUpdate 0& 'Unfreeze the form
'Set the Excel window's enablement to the correct choice
EnableWindow FindWindow("XLMAIN", Application.Caption), 1
End Sub
Nu krijg ik alleen telkens de foutmelding: Fout 400 tijdens de uitvoering. Het formulier wordt al weergegeven, en kan niet modaal worden weergegeven.
Ik heb al dagen zitten zoeken wat precies modaal is en hoe ik het uit deze code kan krijgen. Ik heb ook al tal zal andere codes geprobeerd, maar die geven over het algemeen allemaal foutmeldingen in het hoofdscript van de userform.
Ik hoop dat het op te lossen is en hoor graag jullie reacties.
Mijn dank is in ieder geval groot!!!
Laatst bewerkt: