OnFieldGetText Event

[Top]  [Chapter]  [Previous]  [Next]

Declaration C#

void OnFieldGetText(Object Sender, int Editor, string FieldName, IWPFieldContents Contents)

 

Declaration OCX

OnFieldGetText(ByVal Editor As Long, ByVal FieldName As String, ByVal Contents As WPTDynInt.IWPFieldContents)

 

This event is use by the mail merge feature (see Memo.MergeText) and the reporting engine (see interface IWPReport).

It is used to fill fields with data during the process of mail merge or report creation. The mail merge is started with MergeText. Inside the merge process the event OnFieldGetText is triggered for all fields.

 

The provided interface Contents makes it easy to change the text displayed by the field.

 

Private Sub WPDLLInt1_OnFieldGetText(ByVal Editor As Long, ByVal FieldName As String, ByVal Contents As WPToolsInt.IWPFieldContents)

  If FieldName='NAME' then Contents.StringValue = 'Julian Ziersch'

End Sub

 

 

It is also possible to create or update an image which is placed inside the field. To make this as easy as possible there are two functions LoadImage and LoadPicture. Both methods will not simply replace the contents of the field with a new image but reuse an existing image container object.

 

To create a hyperlink inside the field use InputHyperlink. You can also load a file with formatted text using LoadText

 

To create a table with data inside the field execute AddTable. The event OnCreateNewCell can be used to format and fill each new cell.

 

If you know that you do not need the field after the merge process you can execute DeleteField. The field markers, not the contents will be removed.

 

An interface to access the current field is provided as property FieldObject. You can use this interface to read other properties of the merge field.

Note

If you are using the Active-X and your developing system does not provide access to the interface passed as parameter, use the property EventField instead.

Note

The event is also used for report group variables in the "add:" mode. Here only the StringValue may be modified. The property FieldObject will be null in this case!


[idh_wpdllint_onfieldgettext.htm]    Copyright © 2007 by WPCubed GmbH