Nayasoch
Board Regular
- Joined
- Sep 9, 2016
- Messages
- 73
Hi there I'm using userform for my Daily Routine with minimize button with following code
I was wondering if there is any way when there are multiple workbooks are opened, if I maximize the userform then as I click maximize button it would select the same workbook in which it contains data from Userform and values userfrom would show as a Result.....!! It would really save me from going insane...For now I need to maximize userform ( as I forget to select workbooks ) and when I click command button then nothing works and from taskbar...I again have to select particular workbooks and then only it works.
Thanks in advance.
Code:
Private Declare Function FindWindowA Lib "user32" _
(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
hWnd = FindWindowA(vbNullString, Me.Caption)
exLong = GetWindowLongA(hWnd, -16)
If (exLong And &H20000) = 0 Then
SetWindowLongA hWnd, -16, exLong Or &H20000
Me.Hide: Me.Show
End If
End Sub
I was wondering if there is any way when there are multiple workbooks are opened, if I maximize the userform then as I click maximize button it would select the same workbook in which it contains data from Userform and values userfrom would show as a Result.....!! It would really save me from going insane...For now I need to maximize userform ( as I forget to select workbooks ) and when I click command button then nothing works and from taskbar...I again have to select particular workbooks and then only it works.
Thanks in advance.