An error occurred initializing the VBA libraries


#1

I faced 2 problem while using aspose.excel.

Firstly,I managed to export the data into excel format, and managed to save it to disk. But once i open the excel file, error occurs with this message in the pop up window :An error occurred initializing the VBA libraries.

If I continue open it, these messages will be shown:
Microsoft Office Excel File Repair Log

Errors were detected in file 'C:\Documents and Settings\doris\Desktop\MediaPlan\MediaPlan2.xls'
The following is a list of repairs:

Lost Visual Basic project.
Lost supporting data on one or more objects.


How to fix it? Is it my coding problem or i need to install/reinstall my excel?I have tried to click the export excel file link from another computer, it gave the same error too.

I am using simple codes to test it.

Dim licenseFile As String = ConfigurationSettings.AppSettings("AsposeLicenseFile")Dim excel As Excel = New Excel(licenseFile)
Dim designerFile As String = ConfigurationSettings.AppSettings("AsposeExcelURL")excel.Open(designerFile)
Dim sheet As Worksheet = excel.Worksheets(0)
sheet.Cells("b5").PutValue("Advertiser")
sheet.Cells("b6").PutValue("Agency")
excel.Save("MediaPlan.xls", SaveType.OpenInExcel, FileFormatType.Default, Me.Response)

My 2nd problem is, if I click to open the excel file instead of save it, i need to click twice in order to open it, why?

My development environment is Dotnetnuke 3.0.13 framework, VB.Net, aspose.excel 2.4.2.0

Any helps will be much appreciated. Thanks in advance.



#2
  1. About the VBA issue, I think your purchased Aspose.Excel is not Enterprise edition. You can verify it by change your code to:

    'Dim licenseFile As String = ConfigurationSettings.AppSettings(“AsposeLicenseFile”)
    'Dim excel As Excel = New Excel(licenseFile)
    Dim excel As Excel = New Excel()
    Dim designerFile As String = ConfigurationSettings.AppSettings(“AsposeExcelURL”)excel.Open(designerFile)
    Dim sheet As Worksheet = excel.Worksheets(0)
    sheet.Cells(“b5”).PutValue(“Advertiser”)
    sheet.Cells(“b6”).PutValue(“Agency”)
    excel.Save(“MediaPlan.xls”, SaveType.OpenInExcel, FileFormatType.Default, Me.Response)


    The trial Aspose.Excel is Enterprise edition except the license watermark.

    2. This is caused by Windows or IE. Some of other users also find this problem. They solved this issue by updating their windows and IE.

#3

Additional information, I have no problem in opening the example excel files downloaded from aspose site. So I don’t think that error occurs is because of my current version of excel.


#4

I have tried to use the code you provided, unfortunately, the VBA error still occurs. Sad


#5

Do you use a template file? And does your template file contain VBA/Macro?


#6

Yes, I am using a template file with macro. Is it the cause?


#7

Yes, I think so.

Please try the following code to see if the problem still occurs:

Dim excel As Excel = New Excel()
Dim designerFile As String = ConfigurationSettings.AppSettings(“AsposeExcelURL”)excel.Open(designerFile)
excel.Save(“MediaPlan.xls”, SaveType.OpenInExcel, FileFormatType.Default, Me.Response)


If it still occurs, please post your template file here. It can only be viewed by you and Aspose developers.


#8

Laurence, thanks for your help. Yes, after removing macro from my template, the error no longer exists. Thanks…