I've created a simple application .net Class that converts an excel spreadsheet into a pdf file. I then get an Excel 2007 application to call this dll which works fine on my development machine.
However, when I deploy it on to a Vista machine, that has both the .net framework and Excel 2007, I get this error:
run-time error '429' activex component can't create object
Even though I am an administrator on the machine, I cannot seem to put signed .net dlls into the GAC.
Can someone please help me resolve this?
This is how I'm calling .net tlb file from Excel 2007.
Sub TestSub()<br>
Dim printLibraryTest As PrintLibrary.Print<br>
Set printLibraryTest = New PrintLibrary.Print <br>
printLibraryTest.ConvertExcelToPdf <br>
End Sub <br>
This is .net library below.
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.
}
Finally
{
// 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();
}
}
}
}