Free Support Forum -

Execute a Macro while Document is open?

I have a document created with Aspose.Words. It contains a macro that runs when the document is opened in Word. The maco cycles through all Fields and updates the document (Pages, Table of Contents, Indexes).

It is amazing how long this macro takes to run. Is there a way for me to execute this macro programmatically without opening Word?

If not through Aspose.Words, is anyone aware of a work-around for this? For example: opening the document using interop processing and then saving it?


Thanks for your inquiry. No, unfortunately you can’t run macro using Aspose.Words. But I don’t think that this macro will take much time to run. I tried using the following macro.

Sub AutoOpen()

Dim aStory As Range

Dim aField As Field

For Each aStory In ActiveDocument.StoryRanges

For Each aField In aStory.Fields


Next aField

Next aStory

End Sub

Maybe you should use a few small documents instead one large.

Best regards.