HasMacros prpoerty toggles to true even for xlsx files after enumerating VbaProject property

Hello
I have a xlsx file. Just a normal one
after through aspose cells (non light cells mode just regular mode), the workbook.HasMacros prpoerty is false.
However, once i access the workbook.VbaProject.Modules property HasMacros turns to true;
Looks like even in xlsx files there are built in module (one for workbook itself and one for each sheet) and looks like this causes the HasMacros to toggle to true once you access and read it

System.Diagnostics.Trace.TraceError(“Workbook before iterting through VBA project hasmacros is {0}”,wb.HasMacro); //prints false
int count = wb.VbaProject.Modules.Count;
System.Diagnostics.Trace.TraceError(“Workbook after iterting through VBA project hasmacros is {0}”, wb.HasMacro);//prints true

My questions

  1. Is there a way to distinguish the default built in macros that exist in a file?

@subbuki,

Please notice, I am able to reproduce the issue as you mentioned using a simple XLSX file. I found once we access the workbook.VbaProject.Modules property, HasMacros turns to true instead of false.
e.g.
Sample code:

Workbook wb = new Workbook("e:\\test2\\Book1.xlsx");
Console.WriteLine("Workbook before iterting through VBA project hasmacros is " + wb.HasMacro); //prints false
int count = wb.VbaProject.Modules.Count;
Console.WriteLine("Workbook after iterting through VBA project hasmacros is " + wb.HasMacro);//prints true

I have logged a ticket with an id “CELLSNET-50146” for your issue. We will look into it soon.

Once we have an update on it, we will let you know.

@subbuki,

We analyzed your issue in details. This is expected behavior so it is not an issue with the APIs. Please note, if you call Workbook.VbaProject property, some macro codes will be added, so Workbook.HasMacro becomes true. If Workbook.HasMacro is false and you do not add VBA project to the file, please do not call Workbook.VbaProject.