[英]run-time error '429' activex component can't create object
我創建了一個簡單的應用程序.net類,它將一個Excel電子表格轉換為pdf文件。 然后,我得到一個Excel 2007應用程序來調用此dll,該dll在我的開發計算機上正常運行。
但是,當我將其部署到同時具有.net框架和Excel 2007的Vista計算機上時,出現此錯誤:
run-time error '429' activex component can't create object
即使我是計算機的管理員,我似乎也無法將簽名的.net dll放入GAC。
有人可以幫我解決這個問題嗎?
這就是我從Excel 2007調用.net tlb
文件的方式。
Sub TestSub()<br>
Dim printLibraryTest As PrintLibrary.Print<br>
Set printLibraryTest = New PrintLibrary.Print <br>
printLibraryTest.ConvertExcelToPdf <br>
End Sub <br>
這是下面的.net庫。
using System;<br>
using System.Collections.Generic;<br>
using System.Runtime.InteropServices;<br>
using System.Text;<br>
using Microsoft.Office.Interop.Excel;<br><br>
namespace PrintLibrary<br>
{<br>
[ClassInterface(ClassInterfaceType.None)]<br>
[Guid("3d0f04d2-9123-48e0-b12f-6c276ff2281b")]<br>
[ProgId("PrintLibrary.Test")]<br>
public class Print<br>
{ <br>
public void ConvertExcelToPdf(string inputFile,string outputFile) <br>
{ <br>
ApplicationClass excelApplication = new ApplicationClass(); <br>
Workbook excelWorkBook = null; <br>
string paramSourceBookPath = inputFile; <br>
object paramMissing = Type.Missing; <br>
string paramExportFilePath = outputFile;
XlFixedFormatType paramExportFormat = XlFixedFormatType.xlTypePDF;
XlFixedFormatQuality paramExportQuality =
XlFixedFormatQuality.xlQualityStandard;
bool paramOpenAfterPublish = false;
bool paramIncludeDocProps = true;
bool paramIgnorePrintAreas = true;
object paramFromPage = Type.Missing;
object paramToPage = Type.Missing;
try
{
// Open the source workbook.
excelWorkBook = excelApplication.Workbooks.Open(paramSourceBookPath,
paramMissing, paramMissing, paramMissing, paramMissing,
paramMissing, paramMissing, paramMissing, paramMissing,
paramMissing, paramMissing, paramMissing, paramMissing,
paramMissing, paramMissing);
// Save it in the target format.
if (excelWorkBook != null)
excelWorkBook.ExportAsFixedFormat(paramExportFormat,
paramExportFilePath, paramExportQuality,
paramIncludeDocProps, paramIgnorePrintAreas, paramFromPage,
paramToPage, paramOpenAfterPublish,
paramMissing);
}
catch (Exception ex)
{
// Respond to the error.
}
最后
{
// Close the workbook object.
if (excelWorkBook != null)
{
excelWorkBook.Close(false, paramMissing, paramMissing);
excelWorkBook = null;
}
// Quit Excel and release the ApplicationClass object.
if (excelApplication != null)
{
excelApplication.Quit();
excelApplication = null;
}
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
GC.WaitForPendingFinalizers();
}
}
}
}
一年之后 ...
是否可能是由於與以下原因相同的原因: http : //support.microsoft.com/kb/313984/en-us
發生錯誤是因為目標計算機缺少應用程序中使用的控件對象的許可證信息。這將生成包含正確版本的Winsock控件的安裝程序包。 但是,除非將控件的實例放在窗體上,否則控件的許可證密鑰將不會編譯到應用程序中。 當您嘗試在運行時實例化對象時,應用程序無法提供許可證密鑰,並且代碼將失敗。 例如,下面的代碼將在設計時正常運行,但在未安裝Visual Basic的計算機上,將在運行時失敗。
似乎與您的案件有關:
解決方法似乎是將控件放在窗體上。
也查看此文章: 運行時錯誤“ 429”
執行時Excel 2007 VB腳本運行時錯誤429:
Set objFSO = CreateObject("Scripting.FileSystemObject").
解:
參考文獻:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.