Migrate Excel 4 macro file to 2010

perp1exed

New Member
Joined
Oct 28, 2011
Messages
20
Hi,

In the process of this I had one problem... the Excel 4 sheet macros have commands that manipulate the menu system. Since 2010 uses ribbon these will obviously no longer work.

So I removed those macro lines that touched the menu system.

There is one macro which calls the File Open dialog box.

The Macro is called OpenFile and its contents are:

=OPEN?()

Now, when I go to macros and manually Run this it works and opens the dialog.

But when I try to assign this macro to the onAction of a custom ribbon button I get an error Sub or Function not defined.

Is there a workaround/fix for this? Why can my ribbons onAction event not fire the macro when I can do it manually?

thanks,

KS
 
Ok, I stumbled across a web page that did the job! rorya you were close :)

The correct way to call a sheet macro is as below:

Application.Run "'SheetName'!MacroName"

And voila - Bob's your Uncle!

thanks all.
 
Upvote 0

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Have you tried:
Code:
Application.run "openfile"

One issue arises still...

After I use the "Open" button from the ribbon to open another Excel file - the ribbon, in the opened file dissappears (maybe because that file has no ribbon). So I am unable to click one of the other buttons which performs operations against the opened file.

Any solutions for this?

The Excel 2002 sheet macro has a =RETURN() command - I'm guessing that this retained the menu, but it is not doing this for 2010.

thanks.
 
Upvote 0
Any customisations you make to the CustomUI only apply to that file unless it is an add-in. You may wish to revert back to the old (but still newer than XLM!) commandbars code to add your buttons to the Addins tab instead, or create an slam file to hold the ribbon customisations.
 
Upvote 0
Thank you.

I am attempting to create an add-in xlam file.

I have added the ribbon and buttons.

When I open my xlsm file, the add-in custom tab is visible now. How do I change the xlam file's vba code to target macros on the xlsm file?

thanks.
 
Upvote 0
I would put the macros in the slam if you can. If not, Application.Run will work across workbooks. (though I don't know if it works with XLM across workbooks - never really bothered with XLM much)
 
Upvote 0
I would put the macros in the slam if you can. If not, Application.Run will work across workbooks. (though I don't know if it works with XLM across workbooks - never really bothered with XLM much)

It does not seem to work across workbooks.

My call is:

Application.Run "'SheetName'!MacroName"

It seems that I cannot save my xlsm file as an xlam file (so I cannot put the macros in an add-in file).

Success seems palpable yet not quite there!

thanks for your assistance.
 
Upvote 0
Also, there error when clicking the buttons is below:

Run-Time error 1004

C:\Users\Public\Documents\Test\Main.xlsx could not be found.

It seems to think the sheet name is the xlsx file name (although it should be xlsm) perhaps I need to pass the FileName!SheetName!Macro, hmmm will try it...
 
Upvote 0
For a normal sheet contained routine (i.e. VBA) it would be:
Code:
'FileName'!SheetName.Macro
 
Upvote 0
Ok this worked...!

Application.Run "Filename.xlsm'!MacroName"

It appears that I do not need the sheetname!

thanks!
 
Upvote 0

Forum statistics

Threads
1,214,987
Messages
6,122,614
Members
449,091
Latest member
gaurav_7829

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top