Accessing Index Field Values

The IAttributes interface represents a collection of index fields. The items in the collection implement the IAttribute interface.

Items in the collection can be accessed either by index (see Using Object Collections) or by index field name. If a specified field does not exist in the collection, an exception will be thrown.

The table below shows how you can access index fields from an Automatic Indexing script.

Language Accessing an Index Field by Index Accessing an Index Field by Name
C# doc.Attributes[0] doc.Attributes["Name"]
Visual Basic .NET doc.Attributes(0) doc.Attributes("Name")
JScript .NET doc.Attributes(0) doc.Attributes("Name")
JScript this.Attributes(0) this.Attributes("Name")
VBScript Me.Attributes(0) Me.Attributes("Name")

You can get and set the value of an index field using the Value property of the IAttribute interface. For example:

// C#
IAttribute attr = doc.Attributes("Name");
var current = attr.Value;
attr.Value = ...;

The type of the value depends on the type of the index field (see the table below).

Index Field Type VARIANT Type .NET Type
DAT_Boolean VT_BOOL bool
DAT_Enumeration VT_BSTR string
DAT_SingleLine VT_BSTR string
DAT_MultipleLines VT_DISPATCH (IStringsCollection) IStringsCollection
DAT_RegularExpression VT_BSTR string
DAT_DateTime VT_DATE DateTime
DAT_Number VT_R8 double
DAT_Currency VT_CY double
DAT_Url VT_BSTR string

Fields of type DAT_MultipleLines can be assigned values that are string arrays or objects of type IStringsCollection. Some examples are provided in the table below.

Language Example
C# doc.Attributes["Authors"].Value = new string[] {"Bob", "Alice"};
Visual Basic .NET doc.Attributes("Authors").Value = new string() {"Bob", "Alice"}
JScript .NET doc.Attributes("Authors").Value = ["Bob", "Alice"];
JScript this.Attributes("Authors").Value = ["Bob", "Alice"];
VBScript Me.Attributes("Authors").Value = Array("Bob", "Alice")

Fields of type DAT_DateTime can be assigned values that are objects of type Date (in VBScript or JScript) or System.DateTime (in .NET languages). Some examples are provided in the table below.

Language Example
C# doc.Attributes["Date"].Value = System.DateTime.Now;
Visual Basic .NET doc.Attributes("Date").Value = System.DateTime.Now
JScript .NET doc.Attributes("Date").Value = System.DateTime.Now;
doc.Attributes("Date").Value = new Date(...);
doc.Attributes("Date").Value = (new Date(...)).getVarDate();
JScript this.Attributes("Date").Value = new Date(...);
this.Attributes("Date").Value = (new Date(...)).getVarDate();
VBScript Me.Attributes("Date").Value = CDate(...)
Me.Attributes("Date").Value = Now

Fields of type DAT_Currency can be assigned values that are numbers of any type or objects of type Currency (in VBScript), System.Decimal (in .NET languages), or System.Runtime.InteropServices.CurrencyWrapper (in .NET languages). Some examples are provided in the table below.

Language Example
C# doc.Attributes["Amount"].Value = 123.456;
doc.Attributes["Amount"].Value = 123.456m;
doc.Attributes["Amount"].Value = new System.Runtime.InteropServices.CurrencyWrapper(123.456m);
Visual Basic .NET doc.Attributes("Amount").Value = 123.456
doc.Attributes("Amount").Value = 123.456D
doc.Attributes("Amount").Value = new System.Runtime.InteropServices.CurrencyWrapper(789.012D)
JScript .NET doc.Attributes("Amount").Value = 123.456;
doc.Attributes("Amount").Value = new System.Decimal(123.456);
doc.Attributes("Amount").Value = new System.Runtime.InteropServices.CurrencyWrapper(123.456);
JScript this.Attributes("Amount").Value = 123.456;
VBScript Me.Attributes("Amount").Value = 123.456
Me.Attributes("Amount").Value = CCur(123.456)

11/29/2022 5:26:42 PM

Please leave your feedback about this article

Usage of Cookies. In order to optimize the website functionality and improve your online experience ABBYY uses cookies. You agree to the usage of cookies when you continue using this site. Further details can be found in our Privacy Notice.