The purpose of this page is to supply a guideline how to handle MS Word document templates with respect to the Organization component.
The possibility to create MS Word documents based upon a template and the data from the application gives the user an easy way to define documents to generate.
The available information that may be used in the document consists of a fixed number of fields that can be mixed with the text in the documents.
There are 48 items defined and supplied in the file employeedata.htm. The file currently includes the following supported database items:
Company Information | Personal Information | Employment Information |
---|---|---|
Company Name | First Name | Emp No |
Association No | Last Name | Date Of Employment |
Company Address | Title | Date Of Leaving |
Company Address 1 | Initials | Employment Comments |
Company Address 2 | External Display Name | Work Time |
Company Zip Code | Address | Leaving Cause |
Company City | Address 1 | Date Start Position |
Company State | Address 2 | Date End Position |
Company County | Zip Code | Position Title |
Company Country | City | Job Title |
Company Phone | State | Manager Name |
Company Fax | County | Manager Job Title |
Company Email | Country | Salary Per Year |
Social Security Number (SSN) | Salary Per Month | |
Gender | Salary Per Hour | |
Date Of Birth | Salary Amount | |
Place Of Birth | Salary Period | |
Salary Pay Frequency | ||
Salary Currency Code |
The newest version of the file employeedata.htm could be found in client\runtime subfolder of <build_home>, which contains installation version of IFS Applications or in client\runtime folder in a delivery of changes in IFS Applications.
The basic data is setup in the window Word Template Definition located in the folder Human Resources / Organization Administration / Settings
The template file name is entered in column named Document. If the file name contains full path then the file is taken from local PC from that path. If the file name doesn't contain path then it is taken from client\runtime folder of application server. After defining of new word template in this form the template file should be placed in suitable folder.
This section gives an example how information about the company and employee is merged into a mail merge document.
The result is a word document with formatted application data.
To create a new document template the user needs to do the following,
All these steps are described in the sections below.
Start Microsoft Word and create a new blank Word document.
Go to Tools/ Mail Merge…
Next, choose to Create Form Letters…
Next, choose Active Window in the dialog.
Select data source by choosing Open Data Source...
Browse to employeedata.htm and select that file, answer Yes on the next question to Edit Main Document
In the upper left corner of the document the alternative Insert Merge Field appears.
All the data that may be fetched from the application is available in this list.
By choosing from these fields and adding text the template is constructed.
To add a Visual Basic Macro go to Tools / Macro / Visual Basic Editor
Add the following code (just copy the code and paste it in the code window),
Public Sub DoMailMerge(sFile As String) ActiveDocument.MailMerge.OpenDataSource Name:=sFile, _ ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _ AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="", _ WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False, _ Format:=wdOpenFormatAuto, Connection:="", SQLStatement:="", SQLStatement1 :="" With ActiveDocument.MailMerge .Destination = wdSendToNewDocument .MailAsAttachment = False .MailAddressFieldName = "" .MailSubject = "" .SuppressBlankLines = True With .DataSource .FirstRecord = wdDefaultFirstRecord .LastRecord = wdDefaultLastRecord End With .Execute Pause:=False End With End Sub
It looks something like this,
Finally the document should be saved under an understandable name.
Configuration should be done according to description from Basic Setup. Then it should be tested e.g. according to description from Running Documents.
To create a new document template the user needs to do the following:
All these steps are described in the sections below.
Start Microsoft Word and create a new blank Word document. Go to Mailings / Start Mail Merge.
Choose to create Letters.
Click on Next and choose Use the current document.
Click on Next and choose Use an existing list. Browse to employeedata.html and select that file.
In Confirm Data Source, select All Web Pages and press OK.
In Mail Merge Recipients check the Data Source and press OK. Then click on Next and write your Letter.
Click on Insert Merge Fields to get the list of data that may be fetched from the application.
By choosing from these fields and adding text the template is constructed.
To add a Visual Basic Macro go to Developer / Visual Basic.
Add the following code (just copy the code and paste it in the code window ):
Public Sub DoMailMerge(sFile As String) ActiveDocument.MailMerge.OpenDataSource Name:=sFile, _ ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _ AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="", _ WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False, _ Format:=wdOpenFormatAuto, Connection:="", SQLStatement:="", SQLStatement1 _ :="" With ActiveDocument.MailMerge .Destination = wdSendToNewDocument .MailAsAttachment = False .MailAddressFieldName = "" .MailSubject = "" .SuppressBlankLines = True With .DataSource .FirstRecord = wdDefaultFirstRecord .LastRecord = wdDefaultLastRecord End With .Execute Pause:=False End With End Sub
As in the example in the below:
Then save the file with file type set to Word Macro-Enabled Document (*.docm).
Configuration should be done according to description from Basic Setup. Then it should be tested e.g. according to description from Running Documents.