Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default auto_close and removing menus

The job that I want auto_close to do is to remove menus when the user wants
to close Excel.

My problem is when the user types information in a worksheet and doesn't
save it. Excel will call my auto_close method and I remove the menus that I
created. In this case the user will get a chance to save her file. If the
user presses "Cancel" at this point, Excel stays open. Now Excel is still
open and my menus are removed.

Below is my script. Please let me know if I should be doing instead.
Otherwise I will put a dialog box that says "Do not press Cancel idiot."
(yes, kidding).

Thanks in advance for any suggestions...

------ TIETools.xla Startup Script ------------
Option Explicit

Private Const MY_MENU As String = "&My Menu"
Private Const MY_MENU_ITEM As String = "&Do It"



Sub Auto_Open()
Dim mnu As CommandBarControl
Dim item As CommandBarControl

On Error Resume Next
' Determine whether command bar already exists.
Set mnu = CommandBars("Worksheet Menu Bar").Controls(MY_MENU)
' If command bar does not exist, create it.
If mnu Is Nothing Then
Err.Clear
Set mnu = CommandBars("Worksheet Menu
Bar").Controls.Add(Type:=msoControlPopup)

mnu.Caption = MY_MENU

Set item = mnu.Controls.Add
With item
.Style = msoControlButton
.Caption = MY_MENU_ITEM
.Tag = MY_MENU_ITEM
.OnAction = "TIETools.Main.DoSomething"
End With
End If
ReDim FieldList(1)
End Sub

Private Sub DoSomething()
MsgBox "do it", vbOKOnly, "DoSomething"
End Sub

Sub Auto_Close()
On Error Resume Next
' Delete command bar, if it exists.
CommandBars("Worksheet Menu Bar").Controls(MY_MENU).Delete
End Sub
------ TIETools.xla ------------
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 221
Default auto_close and removing menus

Either make it a Workbook Before Close or use proper punctuation: Do not
press Cancel, Idiot!
*******************
~Anne Troy

www.OfficeArticles.com


"Take It Easy" wrote in message
...
The job that I want auto_close to do is to remove menus when the user

wants
to close Excel.

My problem is when the user types information in a worksheet and doesn't
save it. Excel will call my auto_close method and I remove the menus that

I
created. In this case the user will get a chance to save her file. If

the
user presses "Cancel" at this point, Excel stays open. Now Excel is still
open and my menus are removed.

Below is my script. Please let me know if I should be doing instead.
Otherwise I will put a dialog box that says "Do not press Cancel idiot."
(yes, kidding).

Thanks in advance for any suggestions...

------ TIETools.xla Startup Script ------------
Option Explicit

Private Const MY_MENU As String = "&My Menu"
Private Const MY_MENU_ITEM As String = "&Do It"



Sub Auto_Open()
Dim mnu As CommandBarControl
Dim item As CommandBarControl

On Error Resume Next
' Determine whether command bar already exists.
Set mnu = CommandBars("Worksheet Menu Bar").Controls(MY_MENU)
' If command bar does not exist, create it.
If mnu Is Nothing Then
Err.Clear
Set mnu = CommandBars("Worksheet Menu
Bar").Controls.Add(Type:=msoControlPopup)

mnu.Caption = MY_MENU

Set item = mnu.Controls.Add
With item
.Style = msoControlButton
.Caption = MY_MENU_ITEM
.Tag = MY_MENU_ITEM
.OnAction = "TIETools.Main.DoSomething"
End With
End If
ReDim FieldList(1)
End Sub

Private Sub DoSomething()
MsgBox "do it", vbOKOnly, "DoSomething"
End Sub

Sub Auto_Close()
On Error Resume Next
' Delete command bar, if it exists.
CommandBars("Worksheet Menu Bar").Controls(MY_MENU).Delete
End Sub
------ TIETools.xla ------------



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
BeforeClose vs Auto_Close [email protected] Excel Programming 16 June 3rd 05 10:06 PM
Removing Column and Row labels and menus from screen Dan Winterton Excel Programming 2 December 17th 04 08:11 PM
Overriding Actions of Excel DropDown Menus and Poup Menus Von Shean Excel Programming 2 February 3rd 04 06:43 AM
Auto_Close() needs help Phil Hageman[_3_] Excel Programming 3 November 19th 03 05:56 PM
Auto_Close Luc Benninger Excel Programming 2 October 14th 03 12:34 PM


All times are GMT +1. The time now is 09:05 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"