itsmevic
asked on
Excel 2010: Minimize Excel
Hello Experts -
For some reason the code that I have is not fully minimizing outlook when the macro is engaged. When I click the button, I'd like just the macro its self to remain and to minimize Excel completely in the background. Where am I going wrong with my code?
Sheet 1:
Module 1:
Your suggestions are greatly welcomed! Thank you.
For some reason the code that I have is not fully minimizing outlook when the macro is engaged. When I click the button, I'd like just the macro its self to remain and to minimize Excel completely in the background. Where am I going wrong with my code?
Sheet 1:
Private Sub btnFrmopen_Click()
ActiveWindow.WindowState = xlMinimized
UserForm1.Show vbModeless
End Sub
Module 1:
Private Declare Function GetForegroundWindow Lib "User32.dll" () As Long
Private Declare Function GetWindowLong _
Lib "User32.dll" Alias "GetWindowLongA" _
(ByVal hWnd As Long, _
ByVal nIndex As Long) _
As Long
Private Declare Function SetWindowLong _
Lib "User32.dll" Alias "SetWindowLongA" _
(ByVal hWnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) _
As Long
Private Const WS_THICKFRAME As Long = &H40000
Private Const GWL_STYLE As Long = -16
Public Sub MakeFormResizable()
Dim lStyle As Long
Dim hWnd As Long
Dim RetVal
hWnd = GetForegroundWindow
'Get the basic window style
lStyle = GetWindowLong(hWnd, GWL_STYLE) Or WS_THICKFRAME
'Set the basic window styles
RetVal = SetWindowLong(hWnd, GWL_STYLE, lStyle)
End Sub
Your suggestions are greatly welcomed! Thank you.
What exactly is happening when you click on the button?
ASKER
The macro launches as it should, but Excel does not minimize to the toolbar.
itsmevic
Could you attach a sample workbook with the code you posted?
I've tried installing the code you've posted in a blank workbook with no luck.
By the way, how exactly is the code in Module1 being called/triggered/executed?
Could you attach a sample workbook with the code you posted?
I've tried installing the code you've posted in a blank workbook with no luck.
By the way, how exactly is the code in Module1 being called/triggered/executed?
ASKER
Sample workbook attached.
Desktop-Widget-Checkoff-List-1.xlsm
Desktop-Widget-Checkoff-List-1.xlsm
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Perfect, that worked Mike, thank you!