Creating macros dynamically

Hi,
I am using Aspose.Words 6.1.0 for .NET with Temporary Licence. I created a document using Document class and added some contents to document using DocumentBuilder class and finally i added Table of Contents field at begining of document.
I need to update the Table of Contents on opening the document, so i would like to write a macro for that, how should i create a macro dynamically and how should i attach that macro to object of Document class…
Regards,
SrinuDhulipalla

Hi
Thanks for your request. Unfortunately, Aspose.Words still does not update TOC and IF fields conditions. We are going to support IF and TOC fields evaluation soon. There is an issue #126 in our defect database regarding this. Hopefully, this feature will be supported in Q2-Q3 2009.
As a workaround you can update fields inside the document manually (ctrl+A and F9) or using macro. See the following link to learn more.
https://support.microsoft.com/en-us/topic/the-filename-field-does-not-automatically-update-when-you-open-a-document-in-word-de2bfb95-d990-1ced-a618-5ac0a2ec1be4
You cannot create macros using Aspose.Words. You can create macro in the template document, and use this template for document generating.
Best regards.

I wasn’t able to find a quick answer on how to create a macro that will update the TOC onload.
Could ether of you give me the steps needed?
Edit: ofcourse I figured it out right after
If ActiveDocument.TablesOfContents.Count = 1 Then _
ActiveDocument.TablesOfContents(1).Update
should be added to the AutoOpen() macro as described here:
https://support.microsoft.com/en-us/topic/the-filename-field-does-not-automatically-update-when-you-open-a-document-in-word-de2bfb95-d990-1ced-a618-5ac0a2ec1be4

Hi

Thanks for your request. Yes, you should add AutoOpen macro in your template. You should do this manually in MS Word. Unfortunately, there is no way to add macro programmatically. So you should just follow the steps described here:
https://support.microsoft.com/en-us/topic/the-filename-field-does-not-automatically-update-when-you-open-a-document-in-word-de2bfb95-d990-1ced-a618-5ac0a2ec1be4
Best regards.

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

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

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