JDogg Posted September 2, 2003 Posted September 2, 2003 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. Quote
Leaders dynamic_sysop Posted September 2, 2003 Leaders Posted September 2, 2003 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... Quote
JDogg Posted September 2, 2003 Author Posted September 2, 2003 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. Quote
Leaders dynamic_sysop Posted September 2, 2003 Leaders Posted September 2, 2003 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. Quote
Recommended Posts