Import problem

JDogg

Member
Joined
Aug 26, 2003
Messages
12
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 Im 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. Ive tried both, and my problem still persists.

Thanks in advance.
 
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...
Code:
Dim objXl As Excel.Application()
/// not Microsoft.Interop.Excel etc...
 
I already declare my Excel-related objects exactly like you suggested (but without the brackets):
Code:
Dim Excel As Excel.Application
Dim excelwbk As Excel.Workbook
Dim excelws As Excel.Worksheet
I dont use Interop in my declarations. But the article http://support.microsoft.com/defaul...port/kb/articles/Q301/9/82.ASP&NoWebContent=1 says to put
Code:
Imports Microsoft.Office.Interop
at the top of forms that automate Excel. Thats the line that gives me the error. Do I not need it?

Thanks.
 
nope you dont need that line at the top unless you run the Interop version ( which you arent by the look of it )
just stick with this...
Code:
Dim Excel As Excel.Application
Dim excelwbk As Excel.Workbook
Dim excelws As Excel.Worksheet
and it should be fine.
 

Similar threads

Back
Top