LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default How to initiate macros in user-friendly fashion

Dean,

Here is an example of a menu on the main Excel menu


'If you put code in the appropriate workbook open event, and
'delete it in the close it will exist only for that workbook.

'Here is an example of a building a commandbar on the fly
'when you open a workbook. It adds a sub-menu to the Tools menu.

Private Sub Workbook_Open()
Dim oCb As CommandBar
Dim oCtl As CommandBarPopup
Dim oCtlBtn As CommandBarButton

Set oCb = Application.CommandBars("Worksheet Menu Bar")

Set oCtl = oCb.Controls.Add(Type:=msoControlPopup, temporary:=True)
With oCtl
.Caption = "myMenu"

Set oCtlBtn = .Controls.Add( _
Type:=msoControlButton, _
temporary:=True)
oCtlBtn.Caption = "myMacroButton"
oCtlBtn.FaceId = 161
oCtlBtn.OnAction = "myMacro"

Set oCtlBtn = .Controls.Add( _
Type:=msoControlButton, _
temporary:=True)
oCtlBtn.Caption = "myMacroButton2"
oCtlBtn.FaceId = 161
oCtlBtn.OnAction = "myMacro2"
'etc.
End With
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim oCb As CommandBar

Set oCb = Application.CommandBars("Worksheet Menu Bar")
oCb.Controls("myMeny").Delete
End Sub

'To add this, go to the VB IDE (ALT-F11 from Excel), and in
'the explorer pane, select your workbook. Then select the
'ThisWorkbook object (it's in Microsoft Excel Objects which
'might need expanding). Double-click the ThisWorkbook and
'a code window will open up. Copy this code into there,
'changing the caption and action to suit.

'This is part of the workbook, and will only exist with the
'workbook, but will be available to anyone who opens the
'workbook.




--

HTH

RP
(remove nothere from the email address if mailing direct)


"Grace" wrote in message
...
I have created several macros that I want someone else, who is not that
well-versed, to be able to run easily, over and over. I am afraid to just
assign keyboard controls with a letter (such as cntrl-a), or such things,

as
they might inadvertently trigger a macro when they are just typing stuff

in.

So, something I recall seeing, but don't recall how to set-up, is that the
name of selected (though not all, I hope) macros appear on the Tools
dropdown within EXCEL. Even better, if easy to do, would be the clickable
buttons you can put on a worksheet and click to initiate macros, - but if
that's tricky, I don't need that now.

Can someone tell me how this is done, please?

Thanks much

Dean




 
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
all sheets need the same first 6 columns - user friendly presentat mariekek5 Excel Discussion (Misc queries) 1 June 16th 09 05:07 PM
Making a Form for User-friendly Macros? SeventFloorProfessor Excel Discussion (Misc queries) 1 January 17th 09 04:37 PM
User-friendly lookup solutions needed Sally Excel Discussion (Misc queries) 3 September 26th 07 06:26 AM
I need a user friendly route sheet! Help! :} nrosales84 New Users to Excel 0 September 17th 07 10:10 PM
user friendly filter Vincent[_4_] Excel Programming 3 August 5th 04 09:59 PM


All times are GMT +1. The time now is 12:03 PM.

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

About Us

"It's about Microsoft Excel"