PDA

View Full Version : Prevent Excel From Maximizing When UserForm Is Active



Excelfun
08-20-2014, 11:34 PM
Hi,
When i open workbook, it display Userform & minimize excel from back of userform with the help of code, but when i click on excel icon from taskbar it display again behind the userform, is any way even if click on excel icon on taskbar it will not allow excel window to maximize, i will appreciate any help on this.
i found below thread but it wont help in this.
Excel- Full screen when activated from windows taskbar - Xtreme Visual Basic Talk (http://www.xtremevbtalk.com/showthread.php?t=279496)

Excel Fox
08-21-2014, 12:16 AM
Instead of preventing Excel from maximizing, why don't you simply make the application invisible, whenever your form is open? Here's a sample. Post back if this is not what you needed.

I've just added a few lines to check the visibility toggle, by simply clicking on the userform. But this code you can remove, and is not required for what you were looking for.

Code in user-form

Option Explicit
Dim bln As Boolean

Private Sub UserForm_Activate()

Application.Visible = False
bln = True

End Sub

Private Sub UserForm_Click()

Application.Visible = bln
bln = Not Application.Visible

End Sub

Private Sub UserForm_Terminate()

Application.Visible = True

End Sub


Code in Workbook module (to activate the form immediately :))

Option Explicit

Private Sub Workbook_Open()

frmTest.Show

End Sub