Good morning,
I have a problem with a docm document I’m generating with Aspose.word librairy in Java.
I have a template in a .dotm format with existing VBA source code.
I’m reading and modifying VBA source code and create a new document in docm format.
When I open the generated docm document, my VBA isn’t working till I click on a button and save the document. When I reopen the document everything is working (the size of my document is greater after saving the document too).
Could you please advise on this problem ?
This is my code to modify the VBA source code :
VbaProject project = builder.getDocument().getVbaProject();
if(project != null) {
if(project.getModules().get("ParticipantAspose") != null) {
String addedSourceCode = "Public Function InitParticipantsByOrdreDuJourList()\n" +
" 'BEGIN ASPOSE\n" +
" Dim cParticipantsList As New Collection\n" +
" Dim pParticipant As New Participant\n" +
" Dim cParticipantsByOrdreDuJour As New Collection\n" +
" Set cParticipantsByOrdreDuJour = New Collection\n" +
" Set cParticipantsList = New Collection\n";
// SOME ADDED CODE...
addedSourceCode += " 'END ASPOSE\n" + "End Function";
project.getModules().get("ParticipantAspose").setSourceCode(addedSourceCode);
}
}
I can provide a document as an example if necessary.
Best Regards,
Muyldermans Aurore