Hi,

I need to to do calculations on some numbers that gets injected into my document templates mergefields by an AddIn and its standalone application serving the data.
Tried a lot things like:
=PRODUCT( { MERGEFIELD TE.price }; 1,1)
or
{ = { MERGEFIELD TE.price } * 1,1 }
But it does not work, because it seems like the data isn't available at the time, Word wants to call the formula or do the calculation.
I finally came to use VBA to hook into some after processes, where I did some tests. See my code below.
Sub Application_MailMergeAfterMerge(Document)
MsgBox ("app mailmerge after")
  ActiveDocument.Bookmarks("perc").Range.Fields(1).Result.Text = "hello"
ActiveDocument.Bookmarks("mehraufwand").Range.Fields(1).Result.Text = "abc"
End Sub

Private Sub Document_MailMergeAfterMerge(Document)
MsgBox ("doc mailmerge after")
  ActiveDocument.Bookmarks("perc").Range.Fields(1).Result.Text = "hello"
ActiveDocument.Bookmarks("mehraufwand").Range.Fields(1).Result.Text = "abc"
End Sub
Both routines never gets called.

By watching how the application opens the Word template, it does the following:
1. Opening the Word template (that's the only time where a Document_New() event is fired)
2. Somehow scans for the special tagged mergefields <<TE.price>> and closes the document
3. Opens a window of the document where these tagged mergefields are replaced by the values coming from the application
While these steps are running, two dialogs are shown (maybe from the addin), first telling me, 'Opening template' and second 'Recognizing fields'.

Is there a way to do calculations on that injected data in some kind of an after hook?


Thanks in advance.