none
Can't use Interop Excel and Outlook RRS feed

  • Question

  • Hello,

    I'm writing a program in VB.net for someone, and I need it to access Excel and Outlook. Unfortunately, while I know how to use the Interop stuff, I can't get it referenced in my project. I have installed and reinstalled Office 365 (the trial version at the moment), but it doesn't seem to install the appropriate PIAs.

    I went and downloaded the o2010pia.msi and ran it, but I don't know if it actually did anything. In my Project -> Add Reference I see the following relevant references (amongst a lot of other non-relevant references):

     - Microsoft Office 14.0 Object Library
     - Microsoft Office 15.0 Object Library

    There is no Microsoft Excel or Microsoft Office Excel. It won't let me add 15.0 as a reference, instead it gives me an error saying that I must remove the Microsoft.Office.Core reference first (which isn't in my project References). It does let me add 14.0, but the only Interop it gives is Access.

    Is there a way to download the Excel and Outlook .dll 's and manually put them in? Also, I don't know if this makes a difference here, but I have this trial Office 365 (so the 2013 ones), but the person I'm making the program for has Office 2007.

    Thank you for any help =)
    Thursday, June 19, 2014 9:11 PM

Answers

  • Hi Hynch,

    From the blog link below, it seems that this issue is not relate to install mutiple versions side-by-side.

    Why is VS development not supported with multiple versions of Office?

    Or alternatively, if we delete the Excel and Office PIA references, and use the Add Reference dialog to add a reference to the Excel 2003 and Office 2003 PIAs. Even if you explicitly select the Excel 11.0 Object Library, because of COM registration, you'll end up with a reference to the Excel 2007 (12.0) and Office 2007 PIAs

    But to run the Office solutlion successfully, I suggest you uninstalling all versions of Office and install the latest one.

    Best regards

    Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Monday, June 23, 2014 8:59 AM
    Moderator
  • SUCCESS!

    I uninstalled everything, and then after reading http://social.msdn.microsoft.com/Forums/en-US/7be02d5c-50d8-40fc-8ece-3b91c6a14840/how-to-fix-an-app-using-an-old-interop-assembly-that-cant-be-removed?forum=vbinterop I went and removed the references in my project. Reinstalled, it forced me to download the Click-to-Run, I used the o2010pia.msi, and then the 15.0 object library showed up and let me add it, and then the Excel and Outlook object libraries showed up and let me add them. I still could only actually use the Interop.Access in my project though, so I took out that reference and suddenly I could use Excel and Outlook! It doesn't really make sense, but I guess that somehow the Access was blocking Excel and Outlook.

    I'm very happy, I can move on with the project now =D

    I'm giving Fei's reinstall response the answer mark, and then I'll mark this post as an answer as well if I can so that anyone with this same problem sees it.
    • Marked as answer by Hynch Monday, June 23, 2014 3:16 PM
    Monday, June 23, 2014 3:15 PM

All replies

  • Hi,

    As far as I know, we don’t need to download the Office PIAs manually. It will installed when you install Office if you have .Net framework not older than 2.0. Also you can install it manually using redistributable package (refer to How to: Install Office Primary Interop Assemblies).

    Which version of Visual Studio are you using? You can refer to link below to set up the environment for developing Office solutions:

    Configuring a Computer to Develop Office Solutions

    >> Also, I don't know if this makes a difference here, but I have this trial Office 365 (so the 2013 ones), but the person I'm making the program for has Office 2007.<<

    By default, Office primary interop assemblies (PIAs) do not need to be installed on end user computers if the Embed Interop Types property of each Office PIA reference in the project is set to True, which is the default value. In this scenario, the type information for the PIA types that are used by your solution is embedded into the solution assembly when you build the project. At run time, the embedded type information is used instead of the PIAs to call into the Office application's COM-based object model. For more information about how types from PIAs are embedded into your solution, see Type Equivalence and Embedded Interop Types.

    If the Embed Interop Types property of each Office PIA reference in the project is set to False, Office PIAs must be installed and registered in the global assembly cache on each end user computer that runs the solution. In most cases, the PIAs are installed by default with Office, but you can also include the PIA redistributable as a prerequisite for your solution. For more information, see Office Solution Prerequisites for Deployment (refer to Designing and Creating Office Solutions- Understanding When the Office PIAs Are Required on End User Computers).

    Best regards

    Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, June 20, 2014 9:35 AM
    Moderator
  • Hey,

    Thanks for responding. I'll give a quick summary of the process I went through before posting here.

    Before yesterday I had a different Office installed (I don't remember which, either 2010 or 2013) and my program was accessing Excel and Outlook perfectly well. Then I was having some issues with the Outlook itself (not to do with my program), so I decided to reinstall with 2013. 2013 installed as Click-To-Run, and I'd read that Configuring a Computer to Develop Office Solutions, so I uninstalled and reinstalled, getting the non-Click-To-Run version. Then I opened the same Visual Basic program I had before and it had complaints about the code to do with Interop.Excel.Application and the Outlook one. I messed around with references, but could only get Microsoft Office 14.0 Object Library as a reference. I looked this stuff up and ended up downloading o2010pia.msi from How to: Install Office Primary Interop Assemblies and running it. At this point I didn't know if it had done anything; I run it, it brings up a screen with some writing and a progress bar, then the progress bar fills and it closes, without any message as to the success or failure. It doesn't seem to add anything to my possible project References. Since then I've run o2010pia.msi a couple more times just in case, but basically I can't figure out what else to do.

    My .NET version is 4.0.30319. As for the Configuring a Computer to Develop Office Solutions link, the only thing there that may be a problem is the different Office versions being installed side-by-side. In the start menu I only have Microsoft Office 2013, but in Programs and Features I have

     - Microsoft Office 365 - en - us
     - Microsoft Office 2010 Primary Interop Assemblies

    I'm guessing the 2010 Primary Interop Assemblies came from the o2010pia.msi, but is it possible that that and maybe other stuff I can't see are left over from the Office 2010 I had before, and therefore breaking the rule of don't have two versions side-by-side?
    Friday, June 20, 2014 3:16 PM
  • Hi Hynch,

    From the blog link below, it seems that this issue is not relate to install mutiple versions side-by-side.

    Why is VS development not supported with multiple versions of Office?

    Or alternatively, if we delete the Excel and Office PIA references, and use the Add Reference dialog to add a reference to the Excel 2003 and Office 2003 PIAs. Even if you explicitly select the Excel 11.0 Object Library, because of COM registration, you'll end up with a reference to the Excel 2007 (12.0) and Office 2007 PIAs

    But to run the Office solutlion successfully, I suggest you uninstalling all versions of Office and install the latest one.

    Best regards

    Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Monday, June 23, 2014 8:59 AM
    Moderator
  • Hey,

    Thanks again for replying. I'll do the uninstall and reinstall again then, I really hope it works.


    Thank you for your help!
    Monday, June 23, 2014 2:04 PM
  • SUCCESS!

    I uninstalled everything, and then after reading http://social.msdn.microsoft.com/Forums/en-US/7be02d5c-50d8-40fc-8ece-3b91c6a14840/how-to-fix-an-app-using-an-old-interop-assembly-that-cant-be-removed?forum=vbinterop I went and removed the references in my project. Reinstalled, it forced me to download the Click-to-Run, I used the o2010pia.msi, and then the 15.0 object library showed up and let me add it, and then the Excel and Outlook object libraries showed up and let me add them. I still could only actually use the Interop.Access in my project though, so I took out that reference and suddenly I could use Excel and Outlook! It doesn't really make sense, but I guess that somehow the Access was blocking Excel and Outlook.

    I'm very happy, I can move on with the project now =D

    I'm giving Fei's reinstall response the answer mark, and then I'll mark this post as an answer as well if I can so that anyone with this same problem sees it.
    • Marked as answer by Hynch Monday, June 23, 2014 3:16 PM
    Monday, June 23, 2014 3:15 PM