Calling Word with Navision fields

Hi! This is my first question in this forum. There is some easy method using automatization in NF 2.60 to call to MS Word showing Navision database fields in the Word document (to combine)?. I wanted something similar to templates in Navision Attain for contacts. Thanks in advance. Edited by - rafa_marius on 2002 Feb 03 12:30:40

You have an example in the navision’s developer designer guide (you’ve an example for using navision automation with excel & another for using it with word). Alfonso Pertierra (Spain)apertierra@teleline.es

Sorry! but I believe I have not explained clearly. In the Developer designer guide there are examples with automation nevertheless, I have not seen any reference that allows to call Word (or Excel) with Navision fiels in the header of Word document. What I want to do from NF is something similar to the execution of form 5075 in Attain in the field Attachment No. Is it possible? (well!, almost all is possible but I hope it without an excessive difficulty). Edited by - rafa_marius on 2002 Feb 04 09:32:02

A explanation: rectifying my previous commentary. The fields don’t appear in the head of the Word document else in the tools bar allowing the selection to combine in the document. Edited by - rafa_marius on 2002 Feb 04 09:35:25

Hi, you can use Document Variables in combination with fields in your Office Word Document. This Document Variables are accessible trough automation from Navision. With best regards

Thanks Lukas for your reply but, do you know any example about it?. (Perhaps this is to request too much!).

Hi Marius, you must analyze the Object Model of Office Word, I give you a little example of this: Application | ± Documents | ± Document | ± Variables | ± Variable From the list above you see the various objects that you must define to access a Document Variable in Word. So in Navision you define a var of Automation Datatype for each object you need. In your Office Document you can place a field somewehre in the text that reference the value of a Document Variable like this: { DOCVARIABLE “Name” } or { DOCVARIABLE “Name 2” } where “Name” and “Name 2” are the identifiers of the Document Variables With best regards

Hi I have used code similar to the following to read the names of word mergefields defined in a word template. I expanded the C/Side example a bit. It gets a round the problem of having to access merge fields by index. Note: ‘flds’ is defined as a collection of fields, in Navision this is a defined as a MS Word automation object. An error occures if you try to assign an empty string to a merge field, hence the appended space. The case statement selects the correct field value to assign to the merge field. The chars « and » are added by word. flds := Activedocument.Range.Fields; FOR c := 1 TO Flds.Count DO BEGIN case Flds.Item(c).Result.Text OF ‘«Mergefield_name_1»’ : sTmp:= sTmp := FORMAT(rec.“Field_1”); ‘«Mergefield_name_2»’ : sTmp:= sTmp := FORMAT(rec.“Field_2”); ‘«Mergefield_name_3»’ : sTmp:= sTmp := FORMAT(rec.“Field_3”); ‘«Mergefield_name_4»’ : sTmp:= sTmp := FORMAT(rec.“Field_4”); END; Flds.Item(c).Result.Text := sTmp + ’ '; END; flds.unlink;