Minimizing a user form

S

sudhakar682

Hi,



Does anybody know why I can't shift focus to another excel sheet while
using a minimize button in a userform present in another excel sheet?



I am using the following code:



Also, while running my userform, I am unable to set focus to another
excel sheet that's open already (present in taskbar)



I am using the following code,







Private Declare Function FindWindow Lib "user32" Alias "FindWindowA"
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Private Declare Function GetWindowLongA Lib "user32" (ByVal hWnd As
Long, ByVal nIndex As Long) As Long

Private Declare Function SetWindowLongA Lib "user32" (ByVal hWnd As
Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long





Private Sub UserForm_Activate()

Dim hWnd As Long, exLong As Long



If Application.Version < 9 Then

hWnd = FindWindow("ThunderXFrame", Me.Caption)

Else

hWnd = FindWindow("ThunderDFrame", Me.Caption)

End If

exLong = GetWindowLongA(hWnd, -16)

If (exLong And &H30000) = 0 Then

SetWindowLongA hWnd, -16, exLong Or &H20000

Me.Hide: Me.Show

End If



End Sub





Using Excel 2002/Windows XP



Thanks,

Sudhakar
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top