Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 177
Default What's special about iRibbonControl?

I have an add-in which I'm trying to make compatible with XL2007 while still
supporting earlier versions of Excel. I've replaced my commandbars and
menus with new ribbon stuff. Each of my ribbon button's has an onAction
attribute that specifies the name of a VBA Sub in my add-in.

I'd like to code the subroutine as:

Sub ButtonClick(Control As Object)
or
Sub ButtonClick(Control As Variant)

to maintain compatibility with earlier versions of Excel which I can't do if
I code it as:

Sub ButtonClick(Control As iRibbonControl)

since iRibbonControl isn't defined in the earlier Excel libraries.

Unfortunately my approach doesn't work! When I click the button I get the
message:

run-time error 424
Object required

when my code tries to access one of the public properties of Control. If I
put Control into a Watch window, the type looks OK ("Object/iRibbonControl")
and if I expand it I see the public properties (Context, Id & Tag) but each
property has a value of "<Object required".

Anybody got any explanation?

TIA,

josh

BTW, if I do code the Control argument as iRibbonControl then the rest of my
code works OK.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default What's special about iRibbonControl?

This is what I do, Josh:

Sub BtnOnActionCall(Ctrl As Variant)
Dim Ctrl1 As IRibbonControl
Set Ctrl1 = Ctrl
MsgBox Ctrl1.ID ''Test

Since this sub is only called when run in Excel 2007 there is no problem
declaring Ctrl1 as IRibbonControl within the sub. If you try to compile this
project in Excel 2003 (Debug, Compile) you would get an error, but there is
no reason to do this.

--
Jim
"Josh Sale" <jsale@tril dot cod wrote in message
...
I have an add-in which I'm trying to make compatible with XL2007 while
still supporting earlier versions of Excel. I've replaced my commandbars
and menus with new ribbon stuff. Each of my ribbon button's has an
onAction attribute that specifies the name of a VBA Sub in my add-in.

I'd like to code the subroutine as:

Sub ButtonClick(Control As Object)
or
Sub ButtonClick(Control As Variant)

to maintain compatibility with earlier versions of Excel which I can't do
if I code it as:

Sub ButtonClick(Control As iRibbonControl)

since iRibbonControl isn't defined in the earlier Excel libraries.

Unfortunately my approach doesn't work! When I click the button I get the
message:

run-time error 424
Object required

when my code tries to access one of the public properties of Control. If
I put Control into a Watch window, the type looks OK
("Object/iRibbonControl") and if I expand it I see the public properties
(Context, Id & Tag) but each property has a value of "<Object required".

Anybody got any explanation?

TIA,

josh

BTW, if I do code the Control argument as iRibbonControl then the rest of
my code works OK.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 177
Default What's special about iRibbonControl?

But Jim,

Do you know why (using your example) I can't just do a MsgBox Ctrl.ID? Why
doesn't Ctrl just late bind to the iRibbonControl object as it would to any
other object?

For reasons that go beyond the scope of this ng posting, my add-in does need
to compile without error under XL2003.

josh




"Jim Rech" wrote in message
...
This is what I do, Josh:

Sub BtnOnActionCall(Ctrl As Variant)
Dim Ctrl1 As IRibbonControl
Set Ctrl1 = Ctrl
MsgBox Ctrl1.ID ''Test

Since this sub is only called when run in Excel 2007 there is no problem
declaring Ctrl1 as IRibbonControl within the sub. If you try to compile
this project in Excel 2003 (Debug, Compile) you would get an error, but
there is no reason to do this.

--
Jim



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default What's special about iRibbonControl?

Do you know why

I do not, Josh. I was as surprised as you to see the passed object had to
be recast to be usable.

my add-in does need to compile without error under XL2003.


A sticky wicket, as the Brits say. What I'm doing with my apps that I want
to work in all XL environments is have my main app file load another add-in
under XL2007 with RibbonX, etc. Messy but I think unavoidable.

--
Jim
"Josh Sale" <jsale@tril dot cod wrote in message
...
But Jim,

Do you know why (using your example) I can't just do a MsgBox Ctrl.ID?
Why doesn't Ctrl just late bind to the iRibbonControl object as it would
to any other object?

For reasons that go beyond the scope of this ng posting, my add-in does
need to compile without error under XL2003.

josh




"Jim Rech" wrote in message
...
This is what I do, Josh:

Sub BtnOnActionCall(Ctrl As Variant)
Dim Ctrl1 As IRibbonControl
Set Ctrl1 = Ctrl
MsgBox Ctrl1.ID ''Test

Since this sub is only called when run in Excel 2007 there is no problem
declaring Ctrl1 as IRibbonControl within the sub. If you try to compile
this project in Excel 2003 (Debug, Compile) you would get an error, but
there is no reason to do this.

--
Jim





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default What's special about iRibbonControl?

I was going to suggest this, or parallel versions for Excel 2007 and the
Excel we've known and used for a decade.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"Jim Rech" wrote in message
...
Do you know why


I do not, Josh. I was as surprised as you to see the passed object had to
be recast to be usable.

my add-in does need to compile without error under XL2003.


A sticky wicket, as the Brits say. What I'm doing with my apps that I
want to work in all XL environments is have my main app file load another
add-in under XL2007 with RibbonX, etc. Messy but I think unavoidable.

--
Jim
"Josh Sale" <jsale@tril dot cod wrote in message
...
But Jim,

Do you know why (using your example) I can't just do a MsgBox Ctrl.ID?
Why doesn't Ctrl just late bind to the iRibbonControl object as it would
to any other object?

For reasons that go beyond the scope of this ng posting, my add-in does
need to compile without error under XL2003.

josh




"Jim Rech" wrote in message
...
This is what I do, Josh:

Sub BtnOnActionCall(Ctrl As Variant)
Dim Ctrl1 As IRibbonControl
Set Ctrl1 = Ctrl
MsgBox Ctrl1.ID ''Test

Since this sub is only called when run in Excel 2007 there is no problem
declaring Ctrl1 as IRibbonControl within the sub. If you try to compile
this project in Excel 2003 (Debug, Compile) you would get an error, but
there is no reason to do this.

--
Jim









  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 177
Default What's special about iRibbonControl?

or parallel versions for Excel 2007 and the Excel we've known and used for
a decade.


Ugh!




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 177
Default What's special about iRibbonControl?

A sticky wicket, as the Brits say. What I'm doing with my apps that I
want to work in all XL environments is have my main app file load another
add-in under XL2007 with RibbonX, etc. Messy but I think unavoidable.



Which is exactly the path I've been pursuing.

I wonder why MS isn't more generous in creating conditional constants? How
much can it cost them to create a VBA12 constant to keep poor lonely VBA6
company?

j


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default What's special about iRibbonControl?

Hi Jim,

Is it still a problem if all specific XL2007 code is in a dedicated module,
preferably the last one inserted. If the addin is developed in a lower
version, any time need to do a compile temporarily comment code within
procedures in that module.

I don't have XL2007 so only asking, however that's what I do enable an addin
with later version stuff to work in earlier versions, eg

Dim rb as Rubbish

- even at module level this doesn't seem to cause a problem providing no
code in the module is ever run while developing (in the lower version).

However there probably would be a problem if any code in that module had
been merely run then saved in a later version that does include 'Rubbish'.
If subsequently run in an earlier version it might blow.

Regards,
Peter T

"Jim Rech" wrote in message

my add-in does need to compile without error under XL2003.


A sticky wicket, as the Brits say. What I'm doing with my apps that I

want
to work in all XL environments is have my main app file load another

add-in
under XL2007 with RibbonX, etc. Messy but I think unavoidable.

--
Jim



  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default What's special about iRibbonControl?

Hi Peter-

My experience with XL2007 is just the same as yours is with other version
issues - as long as you do not _run_ a sub where an unknown variable type is
declared, all is cool. That's the point of the code I posted in my original
response to Josh. He's aware of this but says he _has_ to do a Debug,
Compile in a pre-2007 version unfortunately.

My group at work just released our first version of an app (I'm the main XL
developer) that supports all Excel versions from 2000 to 2007. The only
difference is that the app loads an Excel 2007 add-in with RibbonX when run
under Excel 2007, else it builts its menus with Commandbars. So this
technique is tried and true, at least as far as our in-house testing goes.
We don't actually have any users/clients on Excel 2007 yet<g.

--
Jim
"Peter T" <peter_t@discussions wrote in message
...
Hi Jim,

Is it still a problem if all specific XL2007 code is in a dedicated
module,
preferably the last one inserted. If the addin is developed in a lower
version, any time need to do a compile temporarily comment code within
procedures in that module.

I don't have XL2007 so only asking, however that's what I do enable an
addin
with later version stuff to work in earlier versions, eg

Dim rb as Rubbish

- even at module level this doesn't seem to cause a problem providing no
code in the module is ever run while developing (in the lower version).

However there probably would be a problem if any code in that module had
been merely run then saved in a later version that does include 'Rubbish'.
If subsequently run in an earlier version it might blow.

Regards,
Peter T

"Jim Rech" wrote in message

my add-in does need to compile without error under XL2003.


A sticky wicket, as the Brits say. What I'm doing with my apps that I

want
to work in all XL environments is have my main app file load another

add-in
under XL2007 with RibbonX, etc. Messy but I think unavoidable.

--
Jim





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use now() in a special way The Fool on the Hill Excel Discussion (Misc queries) 13 July 13th 07 02:16 PM
Special Welcome Pop Up FARAZ QURESHI Excel Discussion (Misc queries) 3 January 1st 07 10:28 PM
Special Characters aftamath Excel Discussion (Misc queries) 1 October 18th 05 11:02 PM
Very special Alvin Hansen[_2_] Excel Programming 5 December 1st 04 05:15 PM
Dynamic Copy/Paste Special Formulas/Paste Special Values Sharon Perez Excel Programming 3 August 7th 04 09:49 PM


All times are GMT +1. The time now is 10:20 PM.

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

About Us

"It's about Microsoft Excel"