Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi. My program creates an Excel document, so i import Microsoft.Office.Interop. I get the error

"Namespace or type 'Interop' for the imports 'Microsoft.Office.Interop' cannot be found" in my task list. Can anyone tell me why? This may be a simple issue, but I'm new to using Excel in VB... everything I know I learned from some MSDN article. It said I also had to add a reference to "Microsoft Excel Object Library", but when I went to do that I had to choose between version 5.0 and 8.0. I've tried both, and my problem still persists.

 

Thanks in advance.

  • Leaders
Posted

if you want to use the Microsoft.Excel.Interop method, maybe you should look at this microsoft link...

Excel Interop

you cant use the interop version unless you download the interop version package from microsoft, if you use a reference to the Excel object library ( without the interop ) you should do something like this...

Dim objXl As Excel.Application()
'/// not Microsoft.Interop.Excel etc...

Posted

I already declare my Excel-related objects exactly like you suggested (but without the brackets):

Dim Excel As Excel.Application
Dim excelwbk As Excel.Workbook
Dim excelws As Excel.Worksheet

I don't use Interop in my declarations. But the article http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/Q301/9/82.ASP&NoWebContent=1 says to put

Imports Microsoft.Office.Interop

at the top of forms that automate Excel. That's the line that gives me the error. Do I not need it?

 

Thanks.

  • Leaders
Posted

nope you dont need that line at the top unless you run the Interop version ( which you aren't by the look of it )

just stick with this...

Dim Excel As Excel.Application
Dim excelwbk As Excel.Workbook
Dim excelws As Excel.Worksheet

and it should be fine.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...