ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel 2000: maximise a sizeable form? (https://www.excelbanter.com/excel-programming/285277-excel-2000-maximise-sizeable-form.html)

Philippe Oget

Excel 2000: maximise a sizeable form?
 
Hello all

I have set a form to be resizeable, and I would like to give my users the
opportunity
to choose to have this form to start in a maximised state.

How would I do that?

Thanks

BTW I just realised that I am crossposting with the
microsoft.public.office.developer.vba newsgroup. My fault, my apologies to
all.

Philippe
http://uk.geocities.com/philippeoget



Izar Arcturus

Excel 2000: maximise a sizeable form?
 
Basically you need an independent place to store data that
your macro can draw from each time it starts. Here's one
way to do what you are looking for. See my further
comments at the end.

Sub MainMacro()
On Error GoTo 88
Workbooks.Open Filename:= _
"C:\Documents and Settings\My Documents\UserPrefs.xls"
UserForm1.Height = Range("A1").Value
UserForm1.Width = Range("A2").Value
Application.DisplayAlerts = False
ActiveWorkbook.Close
Application.DisplayAlerts = True
If NeverTrue = 3.14 Then
88 UserForm1.Height = 50
UserForm1.Width = 125
End If
UserForm1.Show
End Sub

Private Sub Maximize_Click()
On Error GoTo 99
Workbooks.Open Filename:= _
"C:\Documents and Settings\My Documents\UserPrefs.xls"
If NeverTrue = 3.14 Then
99 Workbooks.Add
ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\My
Documents\UserPrefs.xls", FileFormat:= _
xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False _
, CreateBackup:=False
End If
Range("A1").Value = 200
Range("A2").Value = 200
UserForm1.Height = 200
UserForm1.Width = 200
ActiveWorkbook.Save
Application.DisplayAlerts = False
ActiveWorkbook.Close
Application.DisplayAlerts = True
End Sub

Private Sub Minimize_Click()
On Error GoTo 99
Workbooks.Open Filename:= _
"C:\Documents and Settings\My Documents\UserPrefs.xls"
If NeverTrue = 3.14 Then
99 Workbooks.Add
ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\My
Documents\UserPrefs.xls", FileFormat:= _
xlNormal, Password:="", WriteResPassword:="" _
, ReadOnlyRecommended:=False _
, CreateBackup:=False
End If
Range("A1").Value = 50
Range("A2").Value = 125
UserForm1.Height = 50
UserForm1.Width = 125
ActiveWorkbook.Save
Application.DisplayAlerts = False
ActiveWorkbook.Close
Application.DisplayAlerts = True
End Sub

1) You could save the "UserPrefs" file anywhere on the
user's drive just so long as it will not be deleted or
moved.
2) "Maximize"(or -ise) and "Minimize" are the buttons I
put on my tester userform. You will need to put that code
into the userform code area.

I liked that question. Thank you.

-IA


-----Original Message-----
Hello all

I have set a form to be resizeable, and I would like to

give my users the
opportunity
to choose to have this form to start in a maximised state.

How would I do that?

Thanks

BTW I just realised that I am crossposting with the
microsoft.public.office.developer.vba newsgroup. My

fault, my apologies to
all.

Philippe
http://uk.geocities.com/philippeoget


.



All times are GMT +1. The time now is 11:54 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com