ModifyComputed (Method)

Applies To:

Columns collection

Description:

Enables you to reference an existing column and change its expression while still maintaining the column name. That is, you can recreate the column which might be used by other columns without having to delete it.

Syntax:

Expression.ModifyComputed(NameOrIndex As Value, Expression As String)

Expression Required:

An expression that returns a Columns object

Example:

The first part of the script adds four undefined computed columns. The second part of the script resolves the errors in the computed column:

//This expression causes the four computed items to become undefined
ActiveDocument.Sections["Results"].Columns.AddComputed("Twice","Unit_Sales * 2");
ActiveDocument.Sections["Results"].Columns.AddComputed("Fours","Twice * 2")
ActiveDocument.Sections["Results"].Columns["Twice"].Remove()
ActiveDocument.Sections["Query"].Process()
ActiveDocument.Sections["Results"].Columns.AddComputed("Twice","Unit_Sales * 3");
//This expression resolves the problem
ActiveDocument.Sections["Results"].Columns.AddComputed("Twice","Unit_Sales * 2");
ActiveDocument.Sections["Results"].Columns.AddComputed("Fours","Twice * 2")
ActiveDocument.Sections["Query"].Process()
ActiveDocument.Sections["Results"].Columns.ModifyComputed("Twice", "Unit_Sales *3";