Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA-Make Custom Menu Item Fire

Hello,
I am trying to make my userform "frmSearch" able to be fired up fro
the regular menu. It is loaded right away, but the user needs to b
able to close it and reopen whenever they need it. My code creates th
Menu item, but when I click on it, it does nothing. I have inserted m
code below. I need help by the "TODO: show search agentThanks i
advance, I appreciate any help.

In "This Workbook:"
Private Sub Workbook_Open()
frmSearch.Show

Dim con

For Each con In Application.CommandBars(1).Controls
If con.Caption = "Agent" Then
con.Delete
End If
Next

With Application.CommandBars(1).Controls.Add(msoControl Popup)
.Caption = "Agent"
.OnAction = "Show_frmSearch" 'TODO: show search agent
End With

In a module:
Public Sub Show_frmSearch()
frmSearch.Show
End Su

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default VBA-Make Custom Menu Item Fire

if you code is as it is shown in your email, you need to modify it to look
like this:

With Application.CommandBars(1).Controls.Add(msoControl Popup)
.Caption = "Agent"
.OnAction = "Show_frmSearch" 'TODO: show search agent
End With

--
Regards,
Tom Ogilvy

"d_rodman " wrote in message
...
Hello,
I am trying to make my userform "frmSearch" able to be fired up from
the regular menu. It is loaded right away, but the user needs to be
able to close it and reopen whenever they need it. My code creates the
Menu item, but when I click on it, it does nothing. I have inserted my
code below. I need help by the "TODO: show search agentThanks in
advance, I appreciate any help.

In "This Workbook:"
Private Sub Workbook_Open()
frmSearch.Show

Dim con

For Each con In Application.CommandBars(1).Controls
If con.Caption = "Agent" Then
con.Delete
End If
Next

With Application.CommandBars(1).Controls.Add(msoControl Popup)
Caption = "Agent"
OnAction = "Show_frmSearch" 'TODO: show search agent
End With

In a module:
Public Sub Show_frmSearch()
frmSearch.Show
End Sub


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA-Make Custom Menu Item Fire

Whoops my bad, I actually had it correct in my code. Lost the "." i
the cut and paste transistion. Sorr

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default VBA-Make Custom Menu Item Fire

Your code worked fine for me.

I didn't create the button in the workbook_open event, but using a normal
module worked and since you use Application.Commandbars in the Open event,
it should work. Also, you said the button is getting created successfully,
so I assume it is working.

I assume the Show macro is in the same workbook.

--
Regards,
Tom Ogilvy


"d_rodman " wrote in message
...
Whoops my bad, I actually had it correct in my code. Lost the "." in
the cut and paste transistion. Sorry


---
Message posted from http://www.ExcelForum.com/



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
Excel 2000 Custom Menu Item Larry Bird Excel Discussion (Misc queries) 0 November 8th 05 08:25 PM
in a excel file, how to make a menu item for the .xls file that when clicked on it runs myform.show? example plz Daniel Excel Worksheet Functions 1 July 7th 05 03:52 AM
How do I make Microsoft Query a menu item? gff Excel Discussion (Misc queries) 0 May 6th 05 12:41 AM
Setting OnAction of custom menu item? Ed[_18_] Excel Programming 12 May 10th 04 02:55 PM
Custom Menu Item specific to a workbook Tommy T Excel Programming 1 January 23rd 04 07:34 PM


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