Set and retrieve ID



My question is this. I need to set a ID inside a document, which cannot be altered by

a user, and then when the user sends the document back I need to read that ID in

order to establish which document it was. What would be the best way to set and

retrieve a value inside a document that cannot be altered??

When adding a text field inside Word there is a checkbox under Field Settings called

Fill-in enabled, can I access this property when inserting a textfield with Apose.Word.

PS. I have no code as yet because im looking for the most efficient way to do this.


Answering your second question:

To enable fill-in dialog you need to use /o key when insering the field with document builder:

builder.InsertField(@"FILLIN Input: \o \* MERGEFORMAT", "");

For your first question - there is no straightforward way to do what you want. I will discuss it with my colleagues and let you know.


To set and retrieve the document ID you can use the Document.Variables property. Here is a code sample:

Document doc = new Document(Application.StartupPath + @"\doc1.doc");

// --- write ID

doc.Variables.Add("SecretID", "12345");

doc.Save(Application.StartupPath + @"\doc1_with_id.doc");

// --- read ID

doc = new Document(Application.StartupPath + @"\doc1_with_id.doc");

MessageBox.Show("SecretID = " + doc.Variables["SecretId"]);

These varibles are not easily available to modify from Word itself, but it's possible to modify them using VBA code.


Thanks for the quick response. on both questions.