WPCubed Product Support

Load document, change fields and save new document

Nevermind it was just an error I did, working perfectly now!

#4 ♥ 0
8.3k Views 2 users read 2 min

Thanks for the reply! I'm well on my way to get this working now but I have one last problem.

This is my current code when I enter the form:

WPDLLInt.SetDLLName(Application.StartupPath + @"\WPTextDLL01.DLL");InitializeComponent();wpdllInt1.Memo.LoadFromFile(@"c:\test.rtf", false, "RTF");wpdllInt1.Memo.TextCursor.FieldsFromTokens("[", "]", "PERSON.");wpdllInt1.Memo.MergeText("");

And in my RTF-Document I have some fields like [NAME], [ADDRESS] etc.

And this is my method for changing the values:

private void wpdllInt1_OnFieldGetText(object Sender, int Editor, string FieldName, IWPFieldContents Contents)
{
if (FieldName.Equals("PERSON.NAME"))
Contents.StringValue = "Julian Ziersch";

if (FieldName.Equals("PERSON.ADDRESS"))
Contents.StringValue = "Testaddress 123";
}

The problem is by doing like this it only does the first field, in this example PERSON.NAME-field and doesnt iterate to the other one. How do I get it to go through all of them?

#3 ♥ 0
support

Hi,

in the manual this is described under "mailmerge"

To load and save a file use the IWPMemo interface,

Basically I want to have a document (rtf, word or whatever txtdynamic supports), Load the document, change some fields example: <<NAME>> to "Fredrik" and then save it to a new document.

You will need this methods:

Memo.LoadFromFile
Memo.TextCursor.FieldsFromTokens
Memo.MergeText
Memo.SaveToFile

You will have to use the event OnFieldGetText to find field content for the field names.

Julian[/code]

#2 ♥ 0

Hi!

I dont know if im blind or something but i've been staring throgh the manual for TextDynamic .NET but I cant find the solution for the simplest problem.

Basically I want to have a document (rtf, word or whatever txtdynamic supports), Load the document, change some fields example: <<NAME>> to "Fredrik" and then save it to a new document.

Im developing in visual studio with C#. Is there any code example to accomplish this simple task?

#1 ♥ 0