Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / January 2005

Tip: Looking for answers? Try searching our database.

office and project late binding

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John Smith - 06 Jan 2005 05:32 GMT
Is there an example showing how to do this.

We do not want a different project for each version of office, the
opportunity for inconsistencies between versions will be a problem in the
long run. Alternatively is there a way to build for different versions in
Visual Studio .Net by creating more than one debug and release build?

We desperately need to talk with someone who is an expert on this topic.
Any examples of what to do would be appreciated.

thank you
Mark
Fredrik Wahlgren - 06 Jan 2005 17:19 GMT
> Is there an example showing how to do this.
>
[quoted text clipped - 8 lines]
> thank you
> Mark

> We do not want a different project for each version of office,
Ypu camn't avoid this. You need a separate dll for each version of Office
that you are targeting. However, you don't need two projects. One project
with two solutions will do the trick. The only way to avoid this is to use
VBA6.

I assume your project is a COM add-in.

/Fredrik
sfong@gt.com.au - 06 Jan 2005 22:38 GMT
Fredrik,

Do you mean one project with two solutions in VBA6 or .Net VS?
Jonathan
Fredrik Wahlgren - 06 Jan 2005 23:04 GMT
> Fredrik,
>
> Do you mean one project with two solutions in VBA6 or .Net VS?
> Jonathan

In mean two solutions in VS .NET. Supporting two versions of Office is less
of an issue in VB6.
Can you tell me a little more about your project?

/Fredrik
sfong@gt.com.au - 06 Jan 2005 23:46 GMT
Fredrik

As you already know from other post, I am developing a Addin for
MSProject using .Net and it is going to support 2002 and 2003. They
require different versions of office PIA. If you are saying I need two
phyical VS.Net solution files to compile to against different versions
of MSProject then that is not what I want. I am looking for a single
VS.Net solution file to compile both, of course not at the same time. I
need different VS.Net configuration in a single solution, such as
DEBUG1 and DEBUG2 in configuration manager. In the source code, it need
#if to determine which version that I am compiling with. This is the
idea.

Jonathan
Fredrik Wahlgren - 07 Jan 2005 15:36 GMT
> Fredrik
>
[quoted text clipped - 10 lines]
>
> Jonathan

You need two solutions but they will be hosted by a single project. This
way, you can get 4 add-ins. 2 release versions and 2 debug versions. Am I
missing something? You don't have to build all of these at the same time if
you don't want to. I assume that debug1 is for MSProject 2002 and debug2 is
for MSProject 2003.
/Fredrik

/Fredrik
sfong@gt.com.au - 08 Jan 2005 05:56 GMT
Yes, that is right. Thanks for the help.

Jonathan
JED - 06 Jan 2005 23:55 GMT
> Ypu camn't avoid this. You need a separate dll for each version of
> Office that you are targeting. However, you don't need two projects.
> One project with two solutions will do the trick. The only way to
> avoid this is to use VBA6.

The following code will open excel and add a new workbook.  It works
for both Office 2000 and Office 2003 (only have access to those
versions currently).

There may be instances in the object model where versions are not
compatible, but for most of the basic functions they are compatible.
For example I also have New Email, New Task, and New Appointment
working for Outlook 2000 and 2003 as well as Mail Merge and Opening of
Word documents in 2000 and 2003.  This is using the same application
executable on different machines.  You should only need separate
assemblies if you are linking to the managed office assemblies, and
they are only available for Office XP and Office 2003.  I have to
target Office 97 onwards unfortunately.

Type _ExcelType = Type.GetTypeFromProgID("Excel.Application");
System.Object _ExcelObj = Activator.CreateInstance(_ExcelType);

object[] args = new object[1];
args[0] = true;
_ExcelObj.GetType().InvokeMember("Visible", BindingFlags.SetProperty,
null, _ExcelObj, args);

System.Object _BookObj = _ExcelObj.GetType().InvokeMember("Workbooks",
BindingFlags.GetProperty, null, _ExcelObj, null);
System.Object _Document = _BookObj.GetType().InvokeMember("Add",
BindingFlags.InvokeMethod, null, _BookObj, null);

cheers,
Jeremy

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
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.