We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Updating and Unlinking fields in Aspose generated documents

The shell documents have set fields in them. I have attached a template to the shell document that Aspose uses to create the documents. The template contains code attached to the docuemnt_open event that updates and unlinks the set fields after aspose has created the document. There are two distinct problems.
One, if there is more than 1 document generated by aspose, the macro only executes on the first document. This is true even though both documents are still attached to the correct template.
Two, if the aspose-generated document is stored in a folder named “splittable,” the document becomes attached to the Normal.dot template. I tried attaching the macro to the document open event of Normal.dot without success. I don’t know where the splittable folder comes from. If I delete that folder, then I get an error message indicating that the missing splittable folder is causing the problem.

How can I get the fields to automatically update and unlink after Aspose has created them?
Thanks for your help,
John D.

Hi
Thanks for your inquiry. I think that you should use the document with macro as a template for creating documents using Aspose.Words. For example you can use the attached document. Or add macro to your templates.
Best regards.

I don’t understand. What you suggest is what I thought I was doing. Are you suggesting that I put the macro in the document instead of the template? I tried that also, but it didn’t work any better.
The documents are being opened in IE7 instead of Word. Does that matter?
Thanks,
John

Hi
Thanks for your request. Yes I suggested adding macro into the document instead template. I tested this on my side and it seems that all works fine. But note macros should be enabled in MS Word. Please see the following link to learn how to enable macros.
http://www.apteryxware.com/dental/knowledgebase/topics/HOWTO__Enable_Macros_In_Microsoft_Word.htm
Also please attach your documents and provide me your code for testing.
Best regards.

Thanks for your input. However, it didn’t resolve the situation. The AutoOpen macro, like the Document_Open macro, only fires when the first document is opened when multiple documents are being opened simultaneously.
You might want to consider using ActiveDocument.Fields.Update instead of looping through each field in the autoopen macro you sent me.
Thanks again for your assitance.

I have included 3 documents and 1 template. I have commented out all code.
Thanks again for your help.

Hi
Thank you for additional information. I look through the document and it seems all should works as expected. I have no ideas why this works on the first document and does not work on other documents.
Please check the following link maybe information provided there could be useful for you.
https://learn.microsoft.com/en-US/office/troubleshoot/word/autoexec-autoopen-macros-word
I tried to open document in the Browser and in the Word and all works fine on my side.
Best regards.

Again, thank you for your assistance.
The link provided some information. It stated that the autoopen macro will not run when called from an automation object which implies that the macro should not run at all.

Hi
But I thought that you didn’t use automation. I thought that you use Aspose.Words to perform mail merge and then open your document in Word. So I don’t think that this is a reason.
Best regards.