Opening VBAProject corrupts Excel Workbook


#1

When I open the VbaProject of a specific Excel file and resave the file, the file is corrupted.

I’m using the code bellow to check if a marcos is in the file. And I’m use the follow file, which results in the RESAVE file. I also check with the latest version 4.6, and the problem still exists.
Excelsheets.zip (219.4 KB)

    int lHasOtherMacros = 0;
try {
  com.aspose.cells.VbaProject lVbaProject = aWorkbook.getVbaProject();
  com.aspose.cells.VbaModuleCollection lModules = lVbaProject.getModules();

  for ( Iterator lIterator = lModules.iterator(); lIterator.hasNext(); ) {
    String lNaam = null;
    try {
      com.aspose.cells.VbaModule lModule = (com.aspose.cells.VbaModule)lIterator.next();
      lNaam = lModule.getName();
      String lCode = lModule.getCodes();
      String lCodeLower = lCode.toLowerCase();
      int lType = lModule.getType();   // VbaModuleType.DOCUMENT

      if( lCodeLower.contains( " sub " ) || lCodeLower.contains( " function " )  ){
        lHasOtherMacros++;
      }
    } catch ( Exception aE ) {
      LOG.error( "hasMacros[100] Bij module: " + lNaam, aE );
    }
  } // for
} catch ( Exception aE ) {
  LOG.error( "hasMacros[101]", aE );
} // try

#2

@inceptionEhv,
The resaved file opens ok in MS Excel 2016 and does not look corrupt. Can you please explain a bit more about output file so that we may analyze further.


#3

The resaved file is have the size off the original file. This happens when you load the VbaProject, if you don’t load it, the filesize stays the same.
When I open this file in office365 i get to see the warning:
The project file … contains invalid key ‘i>>?ID’, --Continue Loading Project?
If I then press Yes I get the following Popup:
_Compile error in hidden module: Buttons. This error commonly occurs when code is incompatible with this version, platform, or architecture of this application. Click Help for information on how to correct this error. _
Both popups are not shown when I open the original file.

2019-07-09 13_50_37-Microsoft Visual Basic for Applications.png (5.7 KB)

2019-07-09 13_49_05-5377-Proposal Barcode Bloedafnameformulier PER POST Engelstalig-RESAVE.xlsm - Ex.png (10.1 KB)


#4

@inceptionEhv,
We were able to observe the issue while using Excel 365 but we need to look into it more. We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSJAVA-42955 - Opening VBAProject corrupts the workbook

#5

@inceptionEhv,
This is to inform you that we have fixed your issue (logged earlier as “CELLSJAVA-42955”) now. We will soon provide you the fixed version after performing QA and incorporating other enhancements and fixes.


#6

@inceptionEhv,

Please try our latest version/fix: Aspose.Cells for Java v19.6.5:

Your issue should be fixed in it.
aspose-cells-19.6.5.zip (6.5 MB)

Let us know your feedback.


#7

The issues you have found earlier (filed as CELLSJAVA-42955) have been fixed in Aspose.Cells for Java 19.7. This message was posted using BugNotificationTool from Downloads module by Amjad_Sahi