Free Support Forum - aspose.com

How to remove Macros vba codes in Excel files in Java

How i remove macro for excel files with aspose cells?
This message was posted using Aspose.Live 2 Forum

Hi,


Please check the following reference documentation on Aspose.Cells for .Net API.
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/aspose.cells.workbookmembers.html

Method in focus is wrokbook.RemoveMacro().

I’m sorry, i forgot to say but i’m using java api.


How i do?

Hi,

I am afraid, the feature is not supported at the moment, we have already logged it as an id: CELLSJAVA-18897. Once we have any update about it, we will let you know here.

Thank you.

Good, i will wait…


thanks.

Hi,

FYI: The average wait time for a fix is 2~3 working days.

Hi,

We have added a new method namely Workbook.removeMacro() in Aspose.Cells for Java v2.5.2.17 for removing macros. Please download.

Hi,

Thanks for this solution, but my document ocorred one problem about VBA(2) library when i remove macro and open this document manually, my office is full instalation, bellow send model file for test.

Best regards,

Hi,

Is this file your output file (by Aspose.Cells for Java using removeMacro() API)? If so, kindly also attach your input file. We will check your issue soon.

Thank you.

Is a input file, output is send in attachment

Hi,

I can find the issue as you mentioned using my sample code with your input file.

When I opened the output file into Ms Excel, I got errors e.g “File not found”, there is also VBA error etc.

Sample code:


Workbook workBook = new Workbook();

workBook.open(“d:\files\removemacro\modelo.xls”);

workBook.removeMacro();

workBook.save(“out.xls”);



I have reopened the issue again and we will figure it out soon.

Thank you.

Hi,

Great, is this error. I will waiting for some news.

Best regards,

The issues you have found earlier (filed as 18897) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.

Hi,


Worked, thanks.

@maxdanielton,

Aspose.Cells has included more enhancements for removing macros or vba codes in the Excel spreadsheets. There are more ways to to perform the task:

//Remove VBA codes from the spreadsheet
for (int i = vbaModuleCollection.getCount() - 1; i >= 0; i--) {
vbaModuleCollection.removeAt(i);
System.out.println("Removed " + i+1);
}

Another better way can be you may exclude VBA codes/macros while loading the file into Aspose.Cells object model:
e.g

//Specify the load options
LoadOptions opts = new LoadOptions();
 
//We do not want to load macros/vba codes
opts.setLoadFilter(new LoadFilter(~LoadDataFilterOptions.VBA));
 
//Load the workbook
Workbook wb = new Workbook(srcDir + "sampleFilterVBALoadingWorkbook.xlsx", opts);

For more information on how to use different features via Aspose.Cells APIs, please follow the link below for Aspose.Cells Documenation:
Workbook VBA Project

Download the latest version of Aspose.Cells for .NET from the following link:
Aspose.Cells for Java (Latest Version)

You can download the latest demos Aspose.Cells for Java Demos.