Formats.Item Method

ClosedDescription

Returns a reference to a specified Format object.

This method has the same functionality as the GetFormat method.

ClosedSyntax

Formats.Item(Index)

Where Index can be either an integer or a string specifying the file name of the BarTender document.

ClosedRequirements

Version

BarTender 6.00 or higher

Edition

Automation, Enterprise Automation

ClosedRemarks

Use the Format.Item method to access a specific document that is opened in BarTender. Index can be either an integer value or a string index specifying the document's file name. In VB.NET Format.Item is the default method for the Formats collection object, therefore the Formats.Item method does not have to be specified in order to get a reference to a given Format object. The Format object can be referenced directly using the Formats collection object.

ClosedVB.NET Example

'Declare a BarTender application variable

Dim btApp As BarTender.Application

'Declare a BarTender document variable

Dim btFormat As BarTender.Format

'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, "")

'Open a second BarTender document

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

'Select the first open document

btFormat = btApp.Formats.Item(1)

'Alternatively, use the document's FileName property if it is known

'btFormat = btFormat.Formats.Item("Format1.btw")

'Set focus to the first document

btFormat.Activate()

'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;

// 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, "");

// Open a second BarTender document

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

// Declare an index variable and set to the index value

int index = 1;

// Alternatively, if you plan to use the document's file name,

// Declare a string variable

// string index = "Format1.btw";

// Set the object variable to the value of the index variable

object obj = index;

// Select the first opened document

btFormat = btApp.Formats.Item(ref obj);

// Set focus to the first document

btFormat.Activate();

// End the BarTender process

btApp.Quit(BarTender.BtSaveOptions.btDoNotSaveChanges);