A Microsoft Excel forum. ExcelBanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » ExcelBanter forum » Excel Newsgroups » Excel Programming
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

How to make macros work in both XL2003 and XL2010?!?



 
 
Thread Tools Display Modes
  #1  
Old August 10th 12, 04:28 PM posted to microsoft.public.excel.programming
Charlotte E.[_3_]
external usenet poster
 
Posts: 99
Default How to make macros work in both XL2003 and XL2010?!?

I'm experimenting with Ribbons in 2010, and apparrently I must create
the macro with '(Control As IRibbonControl)' to be able to call the
macro from a ribbon-button.

But this gives an a compile error in XL2003.

My quick test -macro is:

Sub Show_A1(Control As IRibbonControl)

If Range("A1").Value = "" Then
MsgBox "Cell A1 is empty!"
Else
MsgBox "Cell A1 = " & Range("A1").Value
End If

End Sub

How to make macros work in both XL2003 and XL2010 without compiler-error
in either???


CE

Ads
  #2  
Old August 10th 12, 07:14 PM posted to microsoft.public.excel.programming
Living the Dream
external usenet poster
 
Posts: 93
Default How to make macros work in both XL2003 and XL2010?!?

Hi Charlotte

What about testing for the version first before the Ribbon Code is fired.

This is a snippet of code from Ron Debruin's Mail code which tests which
version is running and looks for the applicable security structure
although I think you could use it for your purpose, you will have to
change this to suit..


If Val(Application.Version) < 12 Then 'Version Running is 2000-2003
Call the applicable code.
Else
Select Case Sourcewb.FileFormat
Case 50: Call the applicable code.
Case 51: Call the applicable code.
Case 52: Call the applicable code.
Case Else: Call the applicable code.
End Select
End If

HTH
Mick.



  #3  
Old August 10th 12, 07:22 PM posted to microsoft.public.excel.programming
Charlotte E.[_3_]
external usenet poster
 
Posts: 99
Default How to make macros work in both XL2003 and XL2010?!?


I knew that :-)

That's not the issue here....
....the issue is 'IRibbonControl' object which doesn't exists in
pre-ribbon versions of Excel.

unless there's a way to make a call from a ribbon to a macro without
this, it is impossible to create Excel-files with custom ribbons that
will work in both newer and older versions of Excel.

Surely Microsoft must have thought of that - question is: How???


CE


Den 10.08.2012 20:14, Living the Dream skrev:
> Hi Charlotte
>
> What about testing for the version first before the Ribbon Code is fired.
>
> This is a snippet of code from Ron Debruin's Mail code which tests which
> version is running and looks for the applicable security structure
> although I think you could use it for your purpose, you will have to
> change this to suit..
>
>
> If Val(Application.Version) < 12 Then 'Version Running is 2000-2003
> Call the applicable code.
> Else
> Select Case Sourcewb.FileFormat
> Case 50: Call the applicable code.
> Case 51: Call the applicable code.
> Case 52: Call the applicable code.
> Case Else: Call the applicable code.
> End Select
> End If
>
> HTH
> Mick.
>
>
>

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Make 2007 macros work in 2003 SoilSaver Excel Discussion (Misc queries) 2 May 9th 11 10:14 AM
Make 2 Macros Work as 1 Don Guillett Excel Programming 2 December 22nd 06 07:23 PM
how can i make macros to work when in tools, costumize and option. MOLECULA0_0 Excel Worksheet Functions 2 May 18th 06 04:54 AM
make macros (sub) work for add-in? [email protected] Excel Programming 2 December 30th 05 03:24 AM
How to make the macros work for different Excel versions? aiyer[_30_] Excel Programming 1 July 26th 04 12:52 PM


All times are GMT +1. The time now is 11:40 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Copyright ©2004-2013 ExcelBanter.
The comments are property of their posters.