NamedSubStrings.SetAll Method

ClosedDescription

Sets all data sources using a string that contains the name and value separated by a delimiter.

ClosedSyntax

NamedSubStrings.SetAll(String, Delimiter)

Where

ClosedRequirements

Version

BarTender 6.00 or higher

Edition

Automation, Enterprise

ClosedRemarks

The NamedSubStrings.SetAll method sets all data sources to a value using a string that contains the name and value separated by a delimiter. This function is more efficient than using the Format.SetNamedSubStringValue method, because it only makes one call to set the data source value as opposed to multiple calls.

The following example sets data source values for Name, Address, and Zip. To do this, we need to format the name and value of each data source into a string delimited by a line feed character:

Name <LineFeed>

Jared Stevens <LineFeed>

Address <LineFeed>

123 Street <LineFeed>

Zip <LineFeed>

98296

ClosedVB.NET Example

'Declare a BarTender application variable

Dim btApp As BarTender.Application

'Declare a BarTender document variable

Dim btFormat As BarTender.Format

'Declare a string variable to store the data source value

Dim btNamedSubString As String

'Create a new instance of BarTender

btApp = New BarTender.Application

'Set the BarTender application visible

btApp.Visible = True

'Open a BarTender document

btFormat = btApp.Formats.Open("c:\Format1.btw", False, "")

'Set the name

btNamedSubString = "Name" & vbLf & "Jared Stevens" & vbLf

'Set the address

btNamedSubString = btNamedSubString & "Address" & vbLf & "123 Street" & vbLf

'Set the zip code

btNamedSubString = btNamedSubString & "Zip" & vbLf & "98296" & vbLf

'Set all of the named data source

btFormat.NamedSubStrings.SetAll(btNamedSubString, vbLf)

'End the BarTender process

btApp.Quit(BarTender.BtSaveOptions.btDoNotSaveChanges)

ClosedC# Example

// Declare a BarTender application variable

BarTender.Application btApp;

// Declare a BarTender document variable

BarTender.Format btFormat;

// Declare a string variable to store the data source value

string btNamedSubString;

// Create a new instance of BarTender

btApp = new BarTender.Application();

// Set the BarTender application visible

btApp.Visible = true;

// Open a BarTender document

btFormat = btApp.Formats.Open("c:\\Format1.btw", false, "");

// Set the name

btNamedSubString = "Name" + "\r\n" + "Jared Stevens" + "\r\n";

// Set the address

btNamedSubString = btNamedSubString + "Address" + "\r\n" + "123 Street" + "\r\n";

// Set the zip code

btNamedSubString = btNamedSubString + "Zip" + "\r\n" + "98296" + "\r\n";

// Set all of the named data sources

btFormat.NamedSubStrings.SetAll(btNamedSubString, "\r\n");

// End the BarTender process

btApp.Quit(BarTender.BtSaveOptions.btDoNotSaveChanges);

Related Topics