Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2006

Tip: Looking for answers? Try searching our database.

Conditionally Compile for Word 2007?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gary Hillerson - 27 Nov 2006 18:24 GMT
Hi,

I've got a template that features in menu in earlier versions of Word,
and when it runs in Word 2007, I want it to use a tab on the ribbon
instead. I've got the tab working, and I know how to dynamically
determine (from Application.Version) if I'm running in Word 2007, so I
can make it work.

BUT:  the module that works with the ribbon includes some declarations
(such as iRibbonControl) that are not available in earlier versions of
Word. So I don't think this code will work with earlier versions.

What's the best way to handle this?  Is there a way to conditionally
compile the code?  I know i can conditionally compile for a Macintosh
by including

#if Mac Then
    'this code only included on mac versions
#Else
    'this code only include on PC versions
#End If

but I don't know how to set up a condition like that "Mac" condition
that's built into VBA.

The only other way i can think to do this is to declare the
iRibbonControl parameters in my ribbon callbacks as variants. I assume
that would work, tho it makes the code a bit tougher to understand.

Any advice appreciated

thanks,
 gary
Jean-Guy Marcil - 27 Nov 2006 23:40 GMT
Gary Hillerson  was telling us:
Gary Hillerson nous racontait que :

> Hi,
>
[quoted text clipped - 26 lines]
>
> Any advice appreciated

I believe that if you use totally separate modules you should be OK.

When you call a sub, the compiler only compile the current module, not the
whole project.

So, if you have a central module that contains the version detection code,
which in turn call one of two modules depending on the detection result, it
should work.

Or, see this thread for another idea:
   http://tinyurl.com/tekav

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

Jay Freedman - 28 Nov 2006 01:28 GMT
>Gary Hillerson  was telling us:
>Gary Hillerson nous racontait que :
[quoted text clipped - 41 lines]
>Or, see this thread for another idea:
>    http://tinyurl.com/tekav

I concur. These techniques are the only ways I'm aware of to make the
same code compile in both old and new versions. They work, but they're
nowhere near as convenient as a compiler constant.

I talked to the leader of the Word programmability team in September
2005 about including a conditional compilation constant for Office
2007 like "Mac" and "VB6". For whatever reason, it wasn't implemented.

--
Regards,
Jay Freedman
Microsoft Word MVP        FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.