Security warning after Workbook.getVbaProject() even without any VBA scripts


#1

Hi,

I have two issues,

Issue 1: there is security warning in Excel 2010 when there isn’t any vba scripts in it after Workbook,getVbaProject(). Code piece,
Workbook wb = new Workbook();
VbaProject vbaProject = wb.getVbaProject();
wb.save(“savedByAspose.xls”);

Issue 2: for a excel file that contains vba module scripts, when removes all the scripts using following code, there is still security warning when open in Excel 2010,

	Workbook wb = new Workbook("any xls that contains vba module scripts");
	vbaModuleCollection VbaModuleCollection = Workbook.getVbaProject().getModules();
	for (int i = 0; i < vbaModuleCollection.getCount(); i++) {
		vbaModuleCollection.removeAt(i);
	}
	wb.save("savedByAspose2.xls");

Could you please check?

Thanks,
Hui


#2

@huichen,
Regarding issue 1, we were able to observe the issue 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-42939 - Warning raised by Excel if we only call Workbook.getVbaProject() for a workbook

For your second issue, when I tried to remove VbaModule using above mentioned sample code, it does not remove the module actually in my sample file. Could you please check it with your sample file and share the feedback? Share your sample with us as well along with the feedback. We will analyze it here and provide our feedback after analysis.


#3

Hi,

Regarding issue 2, I’m able to remove the module and vba scripts using the following code, but security warning still raised for the save file,
Workbook wb = new Workbook(“CF15684.xls”);
VbaModuleCollection vbaModuleCollection = wb.getVbaProject().getModules();
for (int i = 0; i < vbaModuleCollection.getCount(); i++) {
vbaModuleCollection.removeAt(i);
}
wb.save(“CF15684_savedByAspose2.xls”);

Sample files : CF15684.zip (581.4 KB)

You can also share your sample file to let me try.

Thanks,
Hui


#4

@huichen,
We were able to observe the issue where security warning is still raised after removing all the Vba Module scripts 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-42940 - Security warning after removing all the VBA module scripts

Regarding my sample file, there is no need for more testing as issue is successfully reproduced using your sample file.


#5

@huichen,

I think you may try to use Workbook.removeMacro() method to remove all the macros and vba codes, see the sample code for your reference:
e.g
Sample code:

Workbook wb = new Workbook("f:\\files\\CF15684.xls");
		wb.removeMacro();
		wb.save("f:\\files\\out1.xls"); 

Let us know if it you still find any issue.


#6

@Amjad_Sahi,

Yes Workbook.removeMacro() will work when we want to remove all macros and vba codes, but it is NOT my case. Sometimes we just want to remove some modules using
vbaModuleCollection.removeAt() and we don’t want know if any other module exists in the collection.

Your solution is, when we call vbaModuleCollection.removeAt() to delete a module, we have to check if all the items in vbaModuleCollection have been removed and if YES we need to call Workbook.removeMacro(). Your suggestion can be a workround solution, but it’s not the ideal one.

Thanks,
Hui


#7

@huichen,

In that case, kindly spare us little time to evaluate the issue (logged as “CELLSJAVA-42939”). Once we figure it out, we will let you know.

If you do not remove all the modules or macros, security warning will always occur.


#8

@huichen,
If you do not want to export VBA project, please call Workbook.RemoveMacro() method and not call Workbook.getVbaProject() method.

If you want to remove all VBA modes, please use the following code:

for (int i = vbaModuleCollection.getCount() - 1; i &gt;= 0; i--) {
vbaModuleCollection.removeAt(i);
System.out.println("Removed " + i+1);
}

These suggestions will work fine with upcoming version/fix. I will share it with you once it is ready.


#9

@huichen,
Please try our latest version/fix: Aspose.Cells for Java v19.6.3:
aspose-cells-19.6.3.zip (6.5 MB)

Your issues should be fixed in it.

Let us know your feedback.


#10

@ahsaniqbalsidiqui

This issue has been fixed in v19.6.3. Thanks for the update and kind help.

Regards,
Hui


#11

@huichen,
You are welcome.


#12

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