FillIn fields

Please, could you inform me of how to use FillIn fields when merging?

While merging, Aspose doesnt ask for the input of the fillin fields? Does an event handle these fields?

{ FILLIN "My question" \* MERGEFORMAT }

Kind regards,
Jan.

Hi Jan,

Thanks for your inquiry. FILLIN field is not a merge field that is why Aspose.Words mail merge engine skips it. However, you can try using the FieldFillIn class to assign values to different attributes of FILLIN field. I hope, this helps.

Best regards,

Is some example code of this FieldFillIn class available?

Kind regards,
Jan Stolk.

Hi Jan,

Thanks for your inquiry. Please try using the following code:

Document doc = new Document(MyDir + @"in.docx");
// Get paragraph you want to append this FieldFillIn field to
Paragraph para = (Paragraph)doc.GetChildNodes(NodeType.Paragraph, true)[0];
// We want to insert a FieldFillIn field like this:
// { FILLIN Test1 \\d Test2 \\o }
// Create instance of FieldFillIn class and lets build the above field code
FieldFillIn field = (FieldFillIn)para.AppendField(FieldType.FieldFillIn, false);
// { FILLIN Test1 }
field.PromptText = "Test1";
// { FILLIN Test1 \\d Test2 }
field.DefaultResponse = "Test2";
// { FILLIN Test1 \\d Test2 \\o }
field.PromptOnceOnMailMerge = true; 
doc.Save(MyDir + @"out.docx");

I hope, this helps.

Best regards,

Hi, thank you for your reply. However, i was referring to a document that has already been made in MS-Word. It contains merge fields and also fill-in fields. So my question is how to make your mailmerge prompt for these fill-in fields.

Kind regards,
Jan Stolk.

Hi Jan,

Thanks for your inquiry. Please try using the following code:

Document doc = new Document(MyDir + @"in.docx");
doc.FieldOptions.UserPromptRespondent = new HandlePrompts();
doc.UpdateFields();
doc.Save(MyDir + @"out.docx");
public class HandlePrompts : IFieldUserPromptRespondent
{
    public string Respond(string promptText, string defaultResponse)
    {
        // User response (i.e. confirmed value contained in the prompt window).
        return "value";
    }
}

I hope, this helps.

Best regards,

Thank you for your reply, this may very well be what i was looking for.

Kind regards,
Jan.

Thank you for your reply, this is exactly what i was looking for.

Kind regards,
Jan.