-
Maximize Excel window
Hi,
I have a UserForm with a "Print" button. when i click it opens a print preview, but, because i minimized the Excel window at workbook open, with the code:
Code:
Application.WindowState = xlMaximized
it doesn't maximize the window and therefore i can't see the 'print preview'.
Here is the code for the commandbutton:
Code:
Private Sub CommandButton8_Click()
Module6.Time
UserForm1.Hide
End Sub
Code:
'PRINT PREVIEW
Function Time()
Application.OnTime Now + TimeSerial(0, 0, 0.5), "showForm"
End Function
Thanks for any help!!
-
Hi,
A few notes:
1. TimeSerial's arguments accepts Integers (you have a double for the Seconds parameter). And by the looks of it, you don't need the Application.OnTime method if the form will show up in half-a-second.
2. You don't need the function "Time" because that 1 line of code can be executed in your CommandButton8 procedure.
3. For your main problem, you can check if Excel's window is minimized, then act appropriately.
Example code:
[vba]Private Sub CommandButton8_Click()
UserForm1.Hide
Call showForm
End Sub
Public Sub showForm()
' Check if Excel is minimized
If (Application.WindowState = xlMinimized) Then _
Application.WindowState = xlMaximized
' Print preview...
End Sub[/vba]
Hope this helps
-
Malik,
Thank you soo much for you patiance!!!! I'll will try this and see what happens... But thank you for you answer and for giving a new look to the code. It looks much more good!