none
How to resolve "Error: Type 'Microsoft.Office.Interop.Excel.Workbook' is not defined." in VB.NET

    Question

  • Hi All,


    I had written some code in VB.NET to read/write from an Excel 2003 file on my previous XP PC.

    Now I have shifted to a Windows 7 machine with Office 2007 installed on it.. I added the COM reference "Microsoft Office 12.0 Object Library" but still get errors like 'Microsoft.Office.Interop.<something>.. Not defined' for the below lines of code.

    • Dim xlApp As Microsoft.Office.Interop.Excel.Application
    • Dim wb As Microsoft.Office.Interop.Excel.Workbook
    • Dim ws As Microsoft.Office.Interop.Excel.Worksheet

    Also what reference should I be adding for the below object..?

    • Dim xmlDoc As MSXML2.DOMDocument   


    I installed '2007 Microsoft Office System Update: Redistributable Primary Interop Assemblies' but that hasn't solved the problem..

    Thanks in advance!

    • Moved by Mark Liu-lxfModerator Monday, July 02, 2012 8:22 AM Excel issue (From:Visual Basic Interop and Upgrade)
    Sunday, July 01, 2012 7:38 PM

Answers

All replies

  • Hi Kent,

    Thanks for you post.

    Your issue has more relationship with Excel. I’d like to move this thread to Excel for developers forum. It will cost a little time to involve the members in this forum. I appreciate your patience.

    Sorry for any inconvenience and have a nice day.


    Mark Liu-lxf [MSFT]
    MSDN Community Support | Feedback to us

    Monday, July 02, 2012 8:21 AM
  • Do you have

    Imports Microsoft.Office.Interop.Excel
    Imports Microsoft.Office.Interop

    at the top of your class?

    The use of MSXML is not supported in .NET http://support.microsoft.com/kb/815112

    Monday, July 02, 2012 1:22 PM
  • Lots of great examples of VB.NET & Excel here:

    http://www.siddharthrout.com/vb-dot-net-and-excel/


    Ryan Shuell


    Monday, July 02, 2012 5:43 PM
  • Hi..

    Thanks for replying..

    Well I didn't have to define it earlier.. I added those 2 lines and got this warning:

    "Warning    1    Namespace or type specified in the Imports 'Microsoft.Office.Interop.Excel' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases."


    Kent Pawar

    Monday, July 02, 2012 8:01 PM
  • Hello,

    Have you tried adding Microsoft.Office,Interop.Excel from the .NET tab under project references? When referencing this dll under .NET tab one DLL is added while under COM three DLL are added.

    Is there any way to try this project on a 32bit OS to see if the issue has something to do in this regards?


    KSG

    Tuesday, July 03, 2012 6:49 PM