upgrading code excel

Public Schedule Face-to-Face & Virtual Instructor-Led Training - View dates & book

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Upgrading code from Excel 2003 to 2010

Upgrading code from Excel 2003 to 2010

resolvedResolved · Urgent Priority · Version 2010

Edited on Fri 25 Mar 2011, 13:11

Robert has attended:
Excel VBA Advanced course

Upgrading code from Excel 2003 to 2010

I have some code from Excel 2003:
Set MenuObject = Application.CommandBars(1). _
Controls.Add(Type:=msoControlPopup, _
Temporary:=True)
MenuObject.Caption = Caption
which works on my machine but not on another person's machine. I think it is security but everything looks the same. I have Googled the problem and it seems that CommandBars work differently now ut this doesn't explain why my version works. Any ideas, please?

RE: Upgrading code from Excel 2003 to 2010

Hi Robert, thanks for your query. The reason your code doesn't work is that there are no command bars in Excel 2007 or 2010 anymore. The interface has been "ribbonised" and there is no longer a CommandBar object/collection in the object model.

Hope this helps,

Anthony

RE: Upgrading code from Excel 2003 to 2010

Thanks for your quick reply, Anthony. Much appreciated. Yes, 2010 relies on the Ribbon rather than the use of CommandBars but reading John Walkenbach's Power Programming with VBA for Excel 2010 it appears that for compatability the CommandBar object is supported in 2010 but it's use is very restricted, eg it can only be used to add items to the Add-Ins tab of the Ribbon. My situation is that my code will work on my machine as required but the code is just ignored on another machine. Very puzzling. I will continue to investigate. Cheers.

 

Training courses

 

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

Excel tip:

Create a unique items table from a duplicating table

1. Ensure that your list has column headings
2. Select the entire list
3. From the menu bar, select DATA, FILTER, ADVANCED FILTER
4. Select "Filter the list, in place", and tick the "Unique Records Only" box
5. Click OK, filtered list appears.

View all Excel hints and tips


Server loaded in 0.07 secs.