[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 916
  • Last Modified:

Visual Studio 2005 / Office 2007 Interop Assemblies

I have a VS2005 windows application that programs and launches MS Word within the code. I have Office 2003 installed on my development machine. On the development machine I have the Office 11 (2003) assemblies referenced and it works okay. I've downloaded and referenced the Office 10 (2002) PIA's (which replaced the Office 11 references in code) and it works okay. But, now with Office 2007 I'm having trouble.

I have an Office 2007 Trial version installed on a test machine. I've also downloaded and installed the Office 12 PIA's (o2007pia.msi) and installed these on the test machine. I did not remove references to Office 11 in code or I get errors. When I run the application on the developement machine a box came up saying it was configuring Office 2007 but then got an error "Interface not registered (Exception from HRESULT: 0x80040155) ... System.Runtime.InteropServices.COMExecption ..."

I guess my questions are: 1) how do I register the PIA's on the development machine? 2) do I need a purchased copy of Office 2007 before it will work? 3) do I need to install Office 2007 on my development machine and then reference the Office 12 assemblies like I do with Office 11?

Thanks for your help!
0
ericole
Asked:
ericole
  • 3
  • 2
1 Solution
 
Bob LearnedCommented:
Your development machine needs to have references to  Office 2007 version 12 in order to get the references worked out.  It gets very confusing when trying to interop with different versions of the Office type libraries.

Bob
0
 
ericoleAuthor Commented:
Bob, thanks. I'll install Office 2007 on the developement machine, and then will be able to install the associated PIA's. It, apparently, requires Office 2007 to be there first. I'll get back to "accept as solution". Let me try it. Its really a pain to juggle all the versions of Office around to check this stuff out.

Eric
0
 
Bob LearnedCommented:
Another way of handling this stuff is to use late-binding, but VB.NET handles that a lot better than C# does.  Plus, I haven't tried it with 2007.

Bob
0
 
ericoleAuthor Commented:
I think I'm doing late binding (in part); I understand, then, that I don't need references.  But when I change the word variable declaration to Object I get the intellisense errors. I need to declare it as a Word.Application for it to work. I guess I don't understand the late binding concept completely. Know any good examples of how to do this?

Thanks,
Eric
0
 
Bob LearnedCommented:
You have to do a lot of work to use late-binding with C#.

Here is an example:

Calling a COM Component From C# (Late Binding)
http://www.c-sharpcorner.com/UploadFile/psingh/CallingCOMComponentFromCSharp12022005231615PM/CallingCOMComponentFromCSharp.aspx

VB.NET doesn't check for properties for an object, so you can reference the property, and if it isn't valid, you'll get a run-time error, instead of a compile-time error.

Bob
0

Featured Post

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now