Your Freeze method does nothing of any value. All it does is find
the hWnd of XLMain, which you can get more simply with
Application.Hwnd.
Try the following to lock the window,
Dim Res As Long
Res = LockWindowUpdate(Application.Hwnd)
and the following to unlock the window
Dim Res As Long
Res = LockWindowUpdate(0&)
--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
"Mikeyhend"
wrote in
message
...
Hi,
Does anyone know how to freeze the active window using windows
API?
I tried this:
Class named FreezeWindow:
Option Explicit
Private Declare Function FindWindow Lib "user32" Alias
"FindWindowA" _
(ByVal ClassName As String, ByVal WindowName As String) As Long
Private Declare Function LockWindowUpdate Lib "user32" _
(ByVal hWndLock As Long) As Long
Public Sub Freeze(Window As Window)
Dim hWnd As Long
hWnd = FindWindow("XLMAIN", Application.Caption)
End Sub
Public Sub Unfreeze()
LockWindowUpdate 0
End Sub
Private Sub Class_Terminate()
Unfreeze
End Sub
and in the macro:
dim FreezeWnd as New FreezeWindow
FreezeWnd.Freeze ActiveWindow
FreezeWnd.Unfreeze
I can't get it to work, don't know what's wrong (still learning
VBA).
Thanks in advance
Mike
--
Mikeyhend
------------------------------------------------------------------------
Mikeyhend's Profile:
http://www.excelforum.com/member.php...o&userid=33400
View this thread:
http://www.excelforum.com/showthread...hreadid=564429