Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default Code locking up until I press the reset button

I have the following code:

'the following code is for the first userform that displays on _open

Option Explicit

Const GWL_STYLE = -16
Const WS_CAPTION = &HC00000
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 DrawMenuBar Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function FindWindowA Lib "user32" (ByVal lpClassName As
String, _
ByVal lpWindowName As String) As Long

Private Sub Userform_Initialize()

Dim lngWindow As Long, lFrmHdl As Long

lFrmHdl = FindWindowA(vbNullString, Me.Caption)
lngWindow = GetWindowLong(lFrmHdl, GWL_STYLE)
lngWindow = lngWindow And (Not WS_CAPTION)

Call SetWindowLong(lFrmHdl, GWL_STYLE, lngWindow)
Call DrawMenuBar(lFrmHdl)

End Sub

'The code above does nothing more than display the userform without a title
bar

Private Sub AddButton_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _
ByVal Shift As Integer)

Dim A As Integer

If Chr(KeyCode) = "A" Then
AddTitle.Show
End If

End Sub

'the following code is for the next userform that displays when you hit the
A key

Option Explicit

Const GWL_STYLE = -16
Const WS_CAPTION = &HC00000
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 DrawMenuBar Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function FindWindowA Lib "user32" (ByVal lpClassName As
String, _
ByVal lpWindowName As String) As Long

Private Sub Userform_Initialize()

Dim lngWindow As Long, lFrmHdl As Long

lFrmHdl = FindWindowA(vbNullString, Me.Caption)
lngWindow = GetWindowLong(lFrmHdl, GWL_STYLE)
lngWindow = lngWindow And (Not WS_CAPTION)

Call SetWindowLong(lFrmHdl, GWL_STYLE, lngWindow)
Call DrawMenuBar(lFrmHdl)

End Sub

When I step through this code it works BUT once the AddTitle userform (the
last userform) displays I can't Alt-F11 to get back to VBE. I can manually
get there with the mouse but once there I have to hit the reset button to
access my code again. Why am I hanging up?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reset button code for Radio Buttons [email protected] Excel Discussion (Misc queries) 6 August 25th 12 03:09 PM
Code locking up until I press the reset button Bishop Excel Programming 0 June 3rd 09 07:45 PM
How do I invoke the "Reset" button in the VB Editior via code? Vinita Excel Programming 5 March 14th 08 06:14 AM
key Press on Forms Button Todd Huttenstine Excel Programming 10 May 21st 04 07:28 PM
Proteting against a button press John Baker Excel Programming 3 October 25th 03 12:14 AM


All times are GMT +1. The time now is 09:29 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"