views:

399

answers:

0

I've created a simple application .Net Class that converts an excel spreadsheet into a a pdf file. I then get a 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 dll into the GAC.

Can someone please help me to resolve this.

This is how i'm calling .net tlb file from Excel 2007.

Sub TestSub()
 Dim printLibraryTest As PrintLibrary.Print
 Set printLibraryTest = New PrintLibrary.Print
  printLibraryTest.ConvertExcelToPdf
End Sub

This is .net library below.

using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
using Microsoft.Office.Interop.Excel;

namespace PrintLibrary
{
[ClassInterface(ClassInterfaceType.None)]
[Guid("3d0f04d2-9123-48e0-b12f-6c276ff2281b")]
[ProgId("PrintLibrary.Test")]
public class Print
{
public void ConvertExcelToPdf(string inputFile,string outputFile)
{
   ApplicationClass excelApplication = new ApplicationClass();
   Workbook excelWorkBook = null;
   string paramSourceBookPath = inputFile;
   object paramMissing = Type.Missing;

       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();
        }  

    }
}

}