Posted to microsoft.public.excel.programming
|
|
How ignore ribbon code when in Excel 2003
This won't eliminate the compile error caused in 2003 by objects and members
introduced in 2007.
- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services, Inc.
http://PeltierTech.com/WordPress/
_______
"exceluserforeman" wrote in
message ...
Public Sub veri()
Dim varVer
varVer = Application.Version
If varVer = 11 Then
'Do 2003 stuff
Else
'do 2007 stuff
End If
End Sub
Put all your code in the same module.
Have 2007 specifics in their own sub routines, even if it is similar to
2003.
You may have repetetive routines that only differ slightly but best to be
specific.
"OssieMac" wrote:
Hi Don,
Just a suggestion and not tested but is it possible to put the code in
another workbook and then only open the other workbook if required. That
way
there should be no need for the code to compile if not required. However,
it
might fail where you attempt to call it because the workbook is not open.
Following code from a post by Bob Phillips.
Application.Run "'another book2.xls'!test_msgbox"
--
Regards,
OssieMac
"donh" wrote:
Jon, Thanks, but that's what I've tried. The Worksheet_Activate is
(conditionally) calling a procedure in the 2007 module, which is where
the
ribbon-invalidation happens. Under 2003, that call would never be
made.
However, it appears that simply having the reference to the 2007 module
procedure in the code causes that procedure to be compiled when the
W_Activate is invoked. Because there is no knowledge of things like
IRibbonUI in Excel 2003, the compile fails and the code is not
executed.
I had hoped that the 2007 module would only be compiled if any of its
procedures was actually invoked, but it appears that its compiled even
if
they are referenced in other source, not just if they are really
called.
Any other ideas? Thanks.
--
Don H.
"Jon Peltier" wrote:
The Worksheet_Activate code can call other procedures. Use some kind
of test
to decide whether to go to a procedure in the 2007 module, and only
this
procedure does the ribbon-invalidation.
- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services, Inc.
http://PeltierTech.com/WordPress/
_______
"donh" wrote in message
...
I have a spreadsheet that is to be useable in both Excel 2007 and
2003. In
the 2007 version, there is customized Ribbon support. I have
isolated all
the ribbon callback functions in a separate VBA module, and it
seems that
when the spreadsheet is opened in Excel 2003 (which of course does
not
invoke
any of the callback functions) that module is never compiled, and
so
everything works.
Except: There is one place where I need to have code that might
call one
of
the ribbon functions: In a Worksheet_Activate method, I need to
invoke
the
IRibbonUI.Invalidate method when in 2007. Even though the code can
test
for
the Application.Version and not call the invalidation procedure,
the very
presence of the statement that references that procedure makes VBA
want to
compile the module that has ribbon code in it. Of course, that
doesn't
work
in Excel 2003 -- none of those objects is known.
Is there any way to "trick" VBA in Excel 2003 into allowing code
that
references ribbon things to compile. I have no intention of
actually
calling
or executing any of that code, but I can't figure out how to keep
it from
being referenced and thus causing compile errors.
One obvious solution is to change the VBA code itself between the
2007 and
2003 versions of the spreadsheet. But the whole point here is to
have a
common set of stuff that works in both places, unchanged.
Thanks,
-don h
--
Don H.
|