upgrading code excel
The UK's Number 1 for Microsoft Office Training Add this page to your favourites/bookmarksBookmark page
 
View printable version of pagePrintable version
Plus One Google
Customer: Sign in
Delegate: Sign in
Trainer: Log in

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

replyReply Fri 25 Mar 2011, 13:02 Edited on Fri 25 Mar 2011, 13:11Delegate Robert said...

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?

For upcoming training course dates see: Pricing & availability

replyReply Fri 25 Mar 2011, 17:07Trainer Anthony said...

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

replyReply Mon 28 Mar 2011, 15:26Delegate Robert said...

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.

 

Please browse our web site to find out more about
excel consultancy and other Microsoft training courses.

Excel tip:

Move or Highlight Cells

Use any of your movement keys, cursor, Home, End, PgUp or PgDn to highlight cells rows or columns by holding down the Shift key as you move.

Use in combination with the Ctrl key for quicker movements.

View all Excel hints and tips


Microsoft Certified Partner Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses Security Seal verified by visa, mastercard securecard