VariableCollectionAdd Method

Adds a document variable to the collection.

Namespace:  Aspose.Words
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.3
Syntax
public void Add(
	string name,
	string value
)

Parameters

name
Type: SystemString
The case-insensitive name of the variable to add.
value
Type: SystemString
The value of the variable. The value cannot be null, if value is null empty string will be used instead.
Examples
Shows how to create document variables and add them to a document's variable collection.
Document doc = new Document(MyDir + "Document.docx");

doc.Variables.Add("doc", "Word processing document");
doc.Variables.Add("docx", "Word processing document");
doc.Variables.Add("txt", "Word processing document");
// Duplicate values can be stored but adding a duplicate name overwrites the old one
doc.Variables.Add("txt", "Plain text file");
doc.Variables.Add("bmp", "Image");
doc.Variables.Add("png", "Image");
See Also