Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default VBA Help required...................!

Dear Friends,

I am trying to insert a dropdown menu on the standard toolbar of excel,
problem is how to call the macro containing the dropdown menu when ever
the excel is opened and to remove the inserted dropdown menu whenever
the excel is closed.

Is this Possible.............?

If Possible please help.........!


Thanks in advance

Ragards
Thyagaraj

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 718
Default VBA Help required...................!

Here is an example:

'-------------------------------------------------
Option Explicit

Dim oMenu As CommandBarPopup

Sub Setmenu()
Set oMenu = CommandBars("Worksheet Menu Bar").Controls.Add( _
Type:=msoControlPopup, _
befo=10, _
temporary:=True)
With oMenu
.Caption = "&Sort"
With .Controls.Add(Type:=msoControlButton)
.Tag = 1
.Caption = "by &Region"
.OnAction = "DoSort"
End With
With .Controls.Add(Type:=msoControlButton)
.Tag = 2
.Caption = "by &District"
.OnAction = "DoSort"
End With
With .Controls.Add(Type:=msoControlButton)
.Tag = 3
.Caption = "by &Volume"
.OnAction = "DoSort"
End With
End With
End Sub

Sub ResetMenu()
oMenu.Delete
End Sub

Sub dosort()
Select Case CommandBars.ActionControl.Tag
Case 1: SortRegion
Case 2: SortDistrict
Case 3: SortVolume
End Select
End Sub

Sub SortRegion()
End Sub

Sub SortDistrict()
End Sub

Sub SortVolume()
End Sub
'------------------------------------------------------------

HTH
--
AP

"Thyagaraj" a écrit dans le message de news:
...
Dear Friends,

I am trying to insert a dropdown menu on the standard toolbar of excel,
problem is how to call the macro containing the dropdown menu when ever
the excel is opened and to remove the inserted dropdown menu whenever
the excel is closed.

Is this Possible.............?

If Possible please help.........!


Thanks in advance

Ragards
Thyagaraj



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default VBA Help required...................!


Ardus Petus wrote:
Here is an example:

'-------------------------------------------------
Option Explicit

Dim oMenu As CommandBarPopup

Sub Setmenu()
Set oMenu = CommandBars("Worksheet Menu Bar").Controls.Add( _
Type:=msoControlPopup, _
befo=10, _
temporary:=True)
With oMenu
.Caption = "&Sort"
With .Controls.Add(Type:=msoControlButton)
.Tag = 1
.Caption = "by &Region"
.OnAction = "DoSort"
End With
With .Controls.Add(Type:=msoControlButton)
.Tag = 2
.Caption = "by &District"
.OnAction = "DoSort"
End With
With .Controls.Add(Type:=msoControlButton)
.Tag = 3
.Caption = "by &Volume"
.OnAction = "DoSort"
End With
End With
End Sub

Sub ResetMenu()
oMenu.Delete
End Sub

Sub dosort()
Select Case CommandBars.ActionControl.Tag
Case 1: SortRegion
Case 2: SortDistrict
Case 3: SortVolume
End Select
End Sub

Sub SortRegion()
End Sub

Sub SortDistrict()
End Sub

Sub SortVolume()
End Sub
'------------------------------------------------------------

HTH
--
AP

"Thyagaraj" a écrit dans le message de news:
...
Dear Friends,

I am trying to insert a dropdown menu on the standard toolbar of excel,
problem is how to call the macro containing the dropdown menu when ever
the excel is opened and to remove the inserted dropdown menu whenever
the excel is closed.

Is this Possible.............?

If Possible please help.........!


Thanks in advance

Ragards
Thyagaraj

Dear Ardus Petus,

This is fine but how to call the SetMenu() when excel is opened and how
to call Reset() when excel is closed.


Regards
Thyagaraj

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default VBA Help required...................!

In a general module:

Sub Auto_open()
call Setmenu
end sub
sub Auto_Close()
call resetmenu
end sub



Thyagaraj wrote:

Ardus Petus wrote:
Here is an example:

'-------------------------------------------------
Option Explicit

Dim oMenu As CommandBarPopup

Sub Setmenu()
Set oMenu = CommandBars("Worksheet Menu Bar").Controls.Add( _
Type:=msoControlPopup, _
befo=10, _
temporary:=True)
With oMenu
.Caption = "&Sort"
With .Controls.Add(Type:=msoControlButton)
.Tag = 1
.Caption = "by &Region"
.OnAction = "DoSort"
End With
With .Controls.Add(Type:=msoControlButton)
.Tag = 2
.Caption = "by &District"
.OnAction = "DoSort"
End With
With .Controls.Add(Type:=msoControlButton)
.Tag = 3
.Caption = "by &Volume"
.OnAction = "DoSort"
End With
End With
End Sub

Sub ResetMenu()
oMenu.Delete
End Sub

Sub dosort()
Select Case CommandBars.ActionControl.Tag
Case 1: SortRegion
Case 2: SortDistrict
Case 3: SortVolume
End Select
End Sub

Sub SortRegion()
End Sub

Sub SortDistrict()
End Sub

Sub SortVolume()
End Sub
'------------------------------------------------------------

HTH
--
AP

"Thyagaraj" a écrit dans le message de news:
...
Dear Friends,

I am trying to insert a dropdown menu on the standard toolbar of excel,
problem is how to call the macro containing the dropdown menu when ever
the excel is opened and to remove the inserted dropdown menu whenever
the excel is closed.

Is this Possible.............?

If Possible please help.........!


Thanks in advance

Ragards
Thyagaraj

Dear Ardus Petus,

This is fine but how to call the SetMenu() when excel is opened and how
to call Reset() when excel is closed.

Regards
Thyagaraj


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA Help required...................!


Enter the following in to ThisWorkbook

Private Sub Workbook_Open()
Call Setmenu
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Call ResetMenu
End Sub

Lee



--
roundabout
------------------------------------------------------------------------
Posted via http://www.mcse.ms
------------------------------------------------------------------------
View this thread: http://www.mcse.ms/message2423610.html

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
Help Required Safi. Excel Worksheet Functions 2 December 31st 07 11:29 PM
Help required kiran New Users to Excel 1 September 1st 05 02:27 PM
Bit of help required. PaulOakley[_7_] Excel Programming 2 July 18th 05 07:20 PM
Help required...... Duncan Excel Discussion (Misc queries) 2 February 17th 05 10:26 PM
Help required in VBA MADS Excel Programming 4 January 10th 05 12:05 PM


All times are GMT +1. The time now is 01:14 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"