使用VS2010,我不能使用VBIDE互操作DLL。有谁能看看他们能不能直接用http://support.microsoft.com/kb/303872在电脑上复制代码?
C:\Program Files\Microsoft Visual Studio 10.0\Visual Studio Tools for Office\PIA\Office14\Microsoft.Vbe.Interop.dll和C:\Program Files\Microsoft Visual Studio 10.0\Visual Studio Tools for Office\PIA\Office14\Microsoft.Vbe.Interop.dll Form_load --把下面的代码://Using statments
using Excel = Microsoft.Office.Interop.Excel;
using VBIDE = Microsoft.Vbe.Interop;
using System.Reflection;
Excel.Application excelApp = null;
Excel._Workbook excelWorkbook;
Excel._Worksheet excelSheet;
excelApp = new Excel.Application();
excelApp.Visible = true;
excelWorkbook = (Excel._Workbook)(excelApp.Workbooks.Add(Missing.Value));
excelSheet = (Excel._Worksheet)excelWorkbook.ActiveSheet;
VBIDE.VBComponent oModule = new VBIDE.VBComponent(); //<--BAM throws an error使用CLSID {BE39F3DA-1B13-11D0-887F-00A0C90F2744}检索组件的COM类工厂,由于以下错误而失败: 80040154类未注册(来自HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)的例外)。
发布于 2011-07-20 04:51:12
工作代码:
VBIDE.VBComponent oModule;
oModule = excelWorkbook.VBProject.VBComponents.Add(VBIDE.vbext_ComponentType.vbext_ct_StdModule);https://stackoverflow.com/questions/6757033
复制相似问题