Hi,
I want to automatically create a word document which will contain some fields from customer table e.g name, contact, address etc. But, i want the user to be able to choose these merge fields in the word document. For example, some users may want to have name, address and contact fields, where some others may just want to have name and address fields only.
I wrote the following code:
wdRange := wdApp.ActiveDocument.Fields.Item(1).Result;
wdRange.Text := Contact;
wdRange := wdApp.ActiveDocument.Fields.Item(2).Result;
wdRange.Text := Name;
wdRange := wdApp.ActiveDocument.Fields.Item(3).Result;
wdRange.Text := Address;
but the problem is that when the user inserts only 2 merge fields in the document (because i do not want it to be a fixed document) i get this error:
"The call to member Item failed. Microsoft returned the following message: The requested member of the collection does not exist".
So, i have to parse the fields in the document and then try to transfer the data from the customer table into the word document. Does anyone wrote some code about this or does anyone have an idea of how to this? I 'm new in Navision and unfortunately i don't have any ideas.
Thanks in advance,
Sophie[/code]
Sophie Christophorou
0
Comments
Perhaps you could look at codeunit 5054 WordManagement and look at the following functions:
ExecuteMerge
ShowMergedDocument
CreateHeader
Maybe this helps.
Regards
Albert