Add File menu to custom toolbar

Hi All,

I am trying to add the 'File" menu and "Window" menu of the Standard
Toolbar to a custom toolbar but failing miserably!

I think it should look something like:

Sub AddMenuTitles()
Application.CommandBars("MyCustomMenu").Controls.Add("File)
Application.CommandBars("MyCustomMenu").Controls.Add("Window")
End Sub

Can anybody help please

Regards

Michael
0
michael
12/17/2009 9:14:00 AM
excel.programming 6508 articles. 2 followers. Follow

4 Replies
1151 Views

Similar Articles

[PageSpeed] 15

Sub test()
    AddMenuTitles True ' or false to delete
End Sub

Sub AddMenuTitles(bAdd As Boolean)
Dim cbr As CommandBar
Dim cbP As CommandBarPopup

    On Error Resume Next
    CommandBars("TestBar").Delete
    On Error GoTo 0
    If Not bAdd Then Exit Sub

' might want to include other arg's in .Add()
    Set cbr = CommandBars.Add("TestBar", temporary:=True)

    Set cbP = cbr.Controls.Add(ID:=30002) ' file
    Set cbP = cbr.Controls.Add(ID:=30003) ' edit

    cbr.Visible = True

End Sub

Regards,
Peter T


"michael.beckinsale" <michael.beckinsale@ntlworld.com> wrote in message 
news:a4f854df-5a02-42b6-a09f-f904f4ffec1e@u7g2000yqm.googlegroups.com...
> Hi All,
>
> I am trying to add the 'File" menu and "Window" menu of the Standard
> Toolbar to a custom toolbar but failing miserably!
>
> I think it should look something like:
>
> Sub AddMenuTitles()
> Application.CommandBars("MyCustomMenu").Controls.Add("File)
> Application.CommandBars("MyCustomMenu").Controls.Add("Window")
> End Sub
>
> Can anybody help please
>
> Regards
>
> Michael 


0
Peter
12/17/2009 9:46:51 AM
Hi Peter,

Many thanks, nice piece of code.

A couple of questions if you dont mind:

1. Where did you get the ID's from?
2. How can l 'anchor' the custom toolbar at sat 'top left' bearing in
mind 3. below?
3. My intention is to delete the users existing Excel menu when
This.Workbook is active, present the user with my custom toolbar, and
then restore the users existing Excel menu when This.Workbook is
inactive. I think l know how to do this using the the
Workbook.Activate & Workbook.Deactivate events but l would br grateful
for any observations / pointers as menu manipulation is not something
l have coded much!

Regards

Michael

0
michael
12/17/2009 10:29:50 AM
(untested)
dim ctr as commandbarcontrol
for each ctr in CommandBars("Worksheet Menu Bar").controls
debug.? ctr.id, ctr.caption
next

The ID of Built-in controls is never 1, You can add copies of built-in 
controls to your bar simply as shown.

Following toggles the main menu bar and docks the custom bar to top

Sub test()
    AddMenuTitles True ' or false to delete
End Sub

Sub AddMenuTitles(bAdd As Boolean)
Dim cbr As CommandBar
Dim cbP As CommandBarPopup

    CommandBars("Worksheet Menu Bar").Enabled = Not bAdd

    On Error Resume Next
    CommandBars("TestBar").Delete
    On Error GoTo 0

    If Not bAdd Then Exit Sub

    Set cbr = CommandBars.Add("TestBar", Position:=msoBarTop, 
temporary:=True)

    Set cbP = cbr.Controls.Add(ID:=30002) ' file
    Set cbP = cbr.Controls.Add(ID:=30003) ' edit

    cbr.Visible = True

End Sub


Always a bit risky messing with user's settings, I tend not to like apps 
that do that. But if needs dictate, call 'AddMenuTitles False' liberally in 
all relevant thisworkbook events when your wb is no longer active, eg 
beforeclose, deavtivate etc.

Regards,
Peter T



"michael.beckinsale" <michael.beckinsale@ntlworld.com> wrote in message 
news:08d4017c-0262-4b6b-b82a-c5d74747f49c@9g2000yqa.googlegroups.com...
> Hi Peter,
>
> Many thanks, nice piece of code.
>
> A couple of questions if you dont mind:
>
> 1. Where did you get the ID's from?
> 2. How can l 'anchor' the custom toolbar at sat 'top left' bearing in
> mind 3. below?
> 3. My intention is to delete the users existing Excel menu when
> This.Workbook is active, present the user with my custom toolbar, and
> then restore the users existing Excel menu when This.Workbook is
> inactive. I think l know how to do this using the the
> Workbook.Activate & Workbook.Deactivate events but l would br grateful
> for any observations / pointers as menu manipulation is not something
> l have coded much!
>
> Regards
>
> Michael
> 


0
Peter
12/17/2009 10:59:54 AM
Hi Peter,

Again thanks very much.

I agree with you re messing about with the users menu settings, hence
my lack of knowledge as l have infrequently coded the menu, however in
this instance the sponsor has requested a 'clean' look!

Regards

Michael

0
michael
12/17/2009 11:55:47 AM
Reply:

Similar Artilces:

What bloated my Outlook.pst file?
Strange story, but true. My Outlook.pst file was getting rather large, over 47 MB, so I decided to do some cleaning. I deleted many unnecessary e-mails (a large portion of my Inbox) , then deleted them from the "Deleted Items" folder. I was surprised, however, to look in my Outlook data folder after that, and saw that the size of the file had increased to over 97 MB, more than double! (I could understand it not decreasing yet, as I hadn't compacted it yet, but didn't understand the increase!) I then compacted it. That shrank it to over 87MB, less than the 97MB+, but still ...

Win32 ToolBar working example
I would like to see a fully working example of a ToolBar implemented in pure Win32. I would prefer that this example be of minimal complexity. Thanks. Hi, The following webLinks should help you out: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/toolbar/toolbar_using.asp http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/toolbar/toolbar_overview.asp Hope these information helps, Kellie. ...

When Customer Details are added in POS
hi we are planning to develop in POS software....we are in analysis phase.....I have a one doubt....when a new customer is arrived to ur store....his/her details want to be stored...When these details can be stored at the time of check out or Check in??? please suggest Dayaa I'm not sure exactly what you are asking about. Are you asking about MS RMS, MS POS or a custome POS application that you are planning to develop? In any of those cases, you should be able to create a new customer record at any time. To do this at the point of sale, it makes the most sense to do it at the begi...

Add Lookup Fields to Entity
I need to add 4 "technical contact" fields (which would lookup the Contact entity) to the CONTRACT form. Is this possible? I've found it difficult to figure out what to do first. Thanks in advance, Brandon Not possible. You cant have multiple lookups for the same entity. You also cannot create new relationships between two system entitites. This will work in 4.0 Not possible, Pezman. N:M relationships are not possible in 3.0 yet. There is a alternative solution: a new entity to act as an N:M relationship. In your case, Contract/Contact. This entity has two 1:N relations...

log file of email open time/date
Hi, I needed to know if there is a way to keep a log file or to view information about when the emails I receive are opened. I probably needed information like date and time. I am the person opening the emails but I needed to show someone when I opened them. Emails are coming from various different people using different email software, so it can't be tracked from their end. I have Outlook 2000, but might need to use it in different versions of Outlook. so if you know of a feature that I can use, can you also tell me if it's available for different versions? thanks a lot. I apprec...

Excel Add Ins
What is the name of the template wizard with Data Tracking (Excel. I can not locate the add in template wizard with Data Tracking in Office 2003 Hi Richard You are not the only one<g> The Add-in is working in 2003 only the install file is not working. Copy the xla file from a PC with 2002 to the PC with 2003 and it will work(use Tools>add-ins to browse to the file in Excel) -- Regards Ron de Bruin http://www.rondebruin.nl "Richard" <Richard@discussions.microsoft.com> wrote in message news:193C5DFD-578D-48F7-B9D6-9FEF5BDCEB64@microsoft.com... > What is t...

Open .msi files as a Limited User by using RUNAS
Windows Registry Editor Version 5.00 ; Open .msi files as a Limited User by using RUNAS ; [HKEY_CLASSES_ROOT\Msi.Package\shell\runas\command] @=hex(2):22,00,25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f, 00,6f,00,74,\ 00,25,00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c, 00,6d,00,\ 73,00,69,00,65,00,78,00,65,00,63,00,2e, 00,65,00,78,00,65,00,22,00,20,00,2f,\ 00,69,00,20,00,22,00,25,00,31,00,22,00,20,00,25,00,2a,00,00,00 That's all very well, but it's not magic! You will still need the correct password of a valid user profile on that machine, tha...

Problems creating a PDF file from a report using autoexec macro
Hi, I am using the autoexec macro to run a report and print it out as a pdf file. My steps in the autoexec macro are 1. OpenReport 2. Print Out 3. RunCode 4. Quit. The RunCode is designed to delay the closing of the application by two minutes so that the pdf file can be created. Whenever I run this, I get a box that comes up and says "Print Macro Definitions" Include for Macro _Properties _Actions and Arguments _Permissions by User and Group. The application hangs on this without closing. Can someone tell me what I am doing wrong? Is Print Out the right command? Tha...

files in OLK folder not being deleted
I having problems with Outlook 2003 not displaying graphics embeded within an email. I've deleted all files in the OLK folder and it works for a few days then I have to delete the files again. I've also tried deleting the folder completely and still the problem returns after a few days use. I thought these were temporary files that should be deleted automatically after the email or Outlook is closed. Why are they not being deleted? I've applied the latest Office patches etc. Hope someone has an answer to the problem. Regards, Lester Bennett Lester Bennett <lbennett@entc...

Add on
Hello, Here is a scenerio. A client is buying 1lb of ham. It is put on a waxed paper then wrapped into a white paper and then put into a shopping bag. The usage of shopping bag is 100% cases the usage of paper is only with certin categories of sales. Same with the waxed paper. Question: Is there a way of associating wax paper, white paper and shopping bags in a way so with every sale a piece of paper gets deducted from inventory and one bag is deducted from inventory? I would like to run a report every so often and see if I need to purchase any supplies. Kits and assembly do not work...

add a row or column to a single cell in exel
I am trying to split a single cell into 2 rows can you help If I understood correctly you want to enter an entry in two lines in a cell at appropirate place hit lt+enter and again hit enter for e.g venkat (alt+enter) raman(enter) "trev" <trev@discussions.microsoft.com> wrote in message news:89B2C15C-057F-43B9-8282-37923D5EA397@microsoft.com... > I am trying to split a single cell into 2 rows can you help ...

way to delete add. fr. auto. email add. function?
Is there a way to delete old or no longer used email addresses that appear in the drop down box when I am addressing a new email? Shebubba wrote: > Is there a way to delete old or no longer used email addresses that appear in > the drop down box when I am addressing a new email? That is the nickname cache. Search and delete the .nk2 file. That's the cache for nicknames (i.e., your manually entered e-mail addresses). If you only want to delete some of them, highlight an entry and hit the delete key. If that doesn't work, use Nirsoft's NK2 Viewer utility (it e...

POS 2009 Add-In: Populating a Task Pad
I would like to create a custom application that has the ability to maintain the items that are on certain Task Pads within POS 2009. These items would all be regular menu items (ex: hamburger, hot dog, french fries, etc) and not functions. For example, if a task pad was supposed to allow the cashier quick access to daily specials, then this custom application would need to be able to clear the task pad each day and add the items for that day. Is this going to be possible? Please provide some guidance. Thank you, Sean This is a multi-part message in MIME format. ------=_NextPart_00...

Add-in cannot be loaded OL07
Every time I open Outlook 2007 I get an error message regarding an add-in 'DCCExtensions' (DCCEXT32.DLL). It says the add-in cannot be loaded and has been disabled by Outlook. I've been getting this message ever since I uninstalled Winfax. How do I make this error stop appearing? Thanks. -- kapibarra Remove the addin from OL by using Trust Center, Addins. http://office.microsoft.com/en-us/outlook/HA100341271033.aspx#14 "kapibarra" wrote: > Every time I open Outlook 2007 I get an error > message regarding an add-in 'DCCExtensions' (DCCEXT32.DLL). ...

microsoft word 2003 save multipage doc to multiple files
Hello! Is there any possible way to resolve my problem : I have 60 page document and id like to split this doc to 60 single paged files. Is there any way to do this whit some magic word option? Reagrds - HE ...

.SRF files are not processed by IIS
Hello, I'm not an IIS expert, so excuse me if this seems like a question I should know the answer to. I was trying to use the CRM 1.2 SDK and was getting a HTTP 405 Not Supported errors from the server. We have another development server, also running 1.2, where the calls go through fine. The difference is that on the machine where everything works when I request a .srf file (ex: http://crmdev/MSCRMServices/BizUser.srf) the file is processed and displays XML output. On the other server, the server that calls fail against, when querying the same response file the contents of the file are...

Edited .MSG files
I have a website that generates invoices. These have to be manually checked for errors. To make things as simple as possible, I created a draft .EML message in Outlook Express that had some special quotes in it, which are automatically changed in PHP. That message is sent as attachment to the person checking the data, so he only has to alter the message, or click "Send" as it is. Everything is filled in Now he's switched to Outlook 2003. I created the same message in Outlook, saved it as a .MSG file and opened it to see if that would work. It does. However, after having the quot...

adding pdf files to a publisher document
I'd like to add a pdf file as a page in Publisher. Can I do this without opening up the pdf file? I can add an object, but pdf is not on the list of objects. No, not unless you have Acrobat (not just the free reader). And even then there seem to be posters who can't but I can with no problem. -- JoAnn Paules MVP Microsoft [Publisher] "campgus" <campgus@discussions.microsoft.com> wrote in message news:F4068A49-7B75-4446-8CA3-37F62ADBEEAD@microsoft.com... > I'd like to add a pdf file as a page in Publisher. Can I do this without > opening up the pdf f...

can't customize outlook today #3
when i click on the customize outlook today button, nothing happen. am i missing something? i'd love to hear from you if you have any ideas about what's happening. thanks! ...

Format text to add character
I have two fields that should match, but one includes special characters while the other does not. Example: Field1 00ABCD123456123 Filed2 00/ABCD/123456/123/SBZ I need to find records where these two fields don't match, either by changing the display of one of them, or a query to compare Field1 character 7-15 with Field2 characters 9-14, 16-18. Hope this makes sense. Can anyone help? Thanks! Take a look at the following from the Access Help file it might be what you're looking for... Extract a part of a text value The following table lists examples of expressions that ...

Identify *.dqy file in Excel #2
Hi, We have some excel files which connects to a ODBC data source (Oracle db) Some of those excel spreadsheets we are not able to edit the data source any longer(which should have brought us into Ms query) What happens when we try is that Ms query opens very shortly and then closes again before we can see the query that have been build) My question is now - is there some way that we can identify what data source (the name of the dqy file) that is used in excel...? Thanks Henrik ...

Add File menu to custom toolbar
Hi All, I am trying to add the 'File" menu and "Window" menu of the Standard Toolbar to a custom toolbar but failing miserably! I think it should look something like: Sub AddMenuTitles() Application.CommandBars("MyCustomMenu").Controls.Add("File) Application.CommandBars("MyCustomMenu").Controls.Add("Window") End Sub Can anybody help please Regards Michael Sub test() AddMenuTitles True ' or false to delete End Sub Sub AddMenuTitles(bAdd As Boolean) Dim cbr As CommandBar Dim cbP As CommandBarPopup ...

Open an odp file in ppt
I have MS Office Home & STudent 07 version & have the PS2 package loaded. I still cannot open an odp file into my ppt program. It says I do not have a file converter but I don't find one anywhere in my searches. =?Utf-8?B?SmVycnk=?= <Jerry@discussions.microsoft.com> wrote in news:843352D9-41F5-4B7F-9FC4-9D580E84702B@microsoft.com: > I have MS Office Home & STudent 07 version & have the PS2 package > loaded. I still cannot open an odp file into my ppt program. It says > I do not have a file converter but I don't find one anywhere in my >...

missing excel VBA help file
I'm missing the excel 97 VBA help file "VEenUl3.hlp". I assume this file is on the software distribution pack that came with my computer. If it is do I reinstall excel or can I just copy the help file from the distribution pack? Finally I may not have the distribution pack since I've moved three times in the five years since the computer was purchased. How would I get a copy if I need it? I'm using windows 98. Thanks for your help John VBA and help files are not part of normal Office install. ie. Office 9 or Excel 97 *not* Windows disk required. Perhaps you ...

attachments converting to .dat files
Anyone have a solution for the following problem: When sending a file attachment, (in this case an .xls) on the receivers end it ends up converted to a .dat file (renaming file to .xls and opening it works though) Both systems are using Outlook 2000, and are sending in HTML (not RTF). Western European(ISO) encoding has been specified as well. The problem only started recently for what seems to be no reason. - L Smith L Smith wrote: > Anyone have a solution for the following problem: > > When sending a file attachment, (in this case an .xls) on > the receivers end it ends ...