Programmatically delete window menu commands

J

Jim Rech

I don't know if there is a way to disable the double-click via the API. If
your concern is that you maximized Excel and users can restore it, you might
try maxing the restore position by including code like this:

Sub MaxRestorePos()
Dim MaxW As Double
Dim MaxH As Double
With Application
.ScreenUpdating = False
.WindowState = xlMaximized
MaxW = .Width
MaxH = .Height
.WindowState = xlNormal
.Left = 0
.Top = 0
.Width = MaxW
.Height = MaxH
End With
End Sub

--
Jim
|I have used the code at
|
| http://support.microsoft.com/default.aspx?scid=kb;en-us;814562
|
| " How to programmatically delete the Window Control menu commands in Excel
| 2002 "
|
| which appears to work , but double clicking the menu bar still allows the
| restore command to work. I am using Excel 2003 in Windows XP.
|
| Any thoughts ?
 
G

Guest

Jim

thanks; this does what I want.

I intend to call this procedure from the Workbook_Open module, but what
would the settings be for .Width & .Height so that I can reset the
conventional restore parameters (either on Workbook_beforeclose or at another
time ) ?
 
J

Jim Rech

I'm glad to here you want to restore the user to where he was. I threw this
together quickly. You'll want to test it and integrate with your API stuff.

Dim OrigLeft As Double
Dim OrigTop As Double
Dim OrigWidth As Double
Dim OrigHeight As Double
Dim OrigState As Integer

Sub MaxRestorePos()
Dim MaxW As Double
Dim MaxH As Double
With Application
.ScreenUpdating = False
OrigState = .WindowState
.WindowState = xlNormal
OrigLeft = .Left
OrigTop = .Top
OrigWidth = .Width
OrigHeight = .Height
.WindowState = xlMaximized
MaxW = .Width
MaxH = .Height
.WindowState = xlNormal
.Left = 0
.Top = 0
.Width = MaxW
.Height = MaxH
End With
End Sub

Sub ResetRestorePos()
With Application
.WindowState = xlNormal ''Just to be sure
.Left = OrigLeft
.Top = OrigTop
.Width = OrigWidth
.Height = OrigHeight
.WindowState = OrigState
End With
End Sub


--
Jim
| Jim
|
| thanks; this does what I want.
|
| I intend to call this procedure from the Workbook_Open module, but what
| would the settings be for .Width & .Height so that I can reset the
| conventional restore parameters (either on Workbook_beforeclose or at
another
| time ) ?
|
|
|
| "Jim Rech" wrote:
|
| > I don't know if there is a way to disable the double-click via the API.
If
| > your concern is that you maximized Excel and users can restore it, you
might
| > try maxing the restore position by including code like this:
| >
| > Sub MaxRestorePos()
| > Dim MaxW As Double
| > Dim MaxH As Double
| > With Application
| > .ScreenUpdating = False
| > .WindowState = xlMaximized
| > MaxW = .Width
| > MaxH = .Height
| > .WindowState = xlNormal
| > .Left = 0
| > .Top = 0
| > .Width = MaxW
| > .Height = MaxH
| > End With
| > End Sub
| >
| > --
| > Jim
| > | > |I have used the code at
| > |
| > | http://support.microsoft.com/default.aspx?scid=kb;en-us;814562
| > |
| > | " How to programmatically delete the Window Control menu commands in
Excel
| > | 2002 "
| > |
| > | which appears to work , but double clicking the menu bar still allows
the
| > | restore command to work. I am using Excel 2003 in Windows XP.
| > |
| > | Any thoughts ?
| >
| >
| >
 
J

Jim Rech

His goal is to prevent Excel itself from being restored, not the workbook.

--
Jim
| How about protect workbook windows but not structure
|
| Regards,
| Peter T
|
| | > I have used the code at
| >
| > http://support.microsoft.com/default.aspx?scid=kb;en-us;814562
| >
| > " How to programmatically delete the Window Control menu commands in
Excel
| > 2002 "
| >
| > which appears to work , but double clicking the menu bar still allows
the
| > restore command to work. I am using Excel 2003 in Windows XP.
| >
| > Any thoughts ?
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top