We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Bookmark "Formfield" value error (Word2003)

Hello,
I use a template (zahtjev.dot) with just one bookmark (for a test). A name of bookmark is “ObrtSubjekt”. There are no data in it. I implemented methods ReadFromBookmark and ReplaceNewLine.
When I read from that bookmark, with the code below, I get som. like " FORMTEXT" value for a string variable “obrtNazivSubjekta”. Where is a problem?

string obrtNazivSubjekta = null;
obrtNazivSubjekta = doc.ReadFromBookmark("ObrtSubjekt");
if (obrtNazivSubjekta == "\n" || obrtNazivSubjekta == "\r" || obrtNazivSubjekta == "\t")
{
    obrtNazivSubjekta = TextUtil.ReplaceNewLine(obrtNazivSubjekta, " ");
}
if (obrtNazivSubjekta != null)
{
    obrtNazivSubjekta = TextUtil.ReplaceNewLine(obrtNazivSubjekta, " ");
    this.Trazitelj.NazivSubjekta = obrtNazivSubjekta;
}

Thnx,
Ivica Andelic.

Sorry, I attached wrong template (with a wrong bookmark name). Here is the right.

Hi
Thanks for your request. There is form field in your document not just bookmark. If you need to get text from the form field, you can use the following code:
doc.Range.FormFields[“ObrtSubjekt1”].Result
Please see the following links to learn how to work with form fields.
https://docs.aspose.com/words/net/working-with-form-fields/
Best regards.