Opening BarTender Documents

The Application object can be used to open one or many BarTender documents. All documents are managed using the Formats collection object, which is used to open and retrieve documents, and to create new ones.

A BarTender document is opened by calling the Formats.Open method. This method returns a Format object, representing the document that was just opened. The following example demonstrates how to open a document in BarTender.

ClosedIn VB.NET

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

'End the BarTender process

btApp.Quit(BarTender.BtSaveOptions.btDoNotSaveChanges)

ClosedIn C#

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

// End the BarTender process

btApp.Quit(BarTender.BtSaveOptions.btDoNotSaveChanges);

The Formats.Open method has three arguments. The first argument is required and is a string containing the path and file name of the document to open. The second argument is a Boolean: if it is true, the method will close the default blank document called "Document1" that BarTender automatically opens when it starts. It cannot close documents that have any other name. The third argument specifies a printer to use.

If you have multiple documents opened in BarTender, you can use the Formats collection object to return a reference to any opened file. A BarTender document can be identified by specifying either the file name or index identifier. You can also bring focus to an opened document using the Format.Activate method. The following example assigns the specified document (Format1.btw) to be the active file in BarTender.

ClosedIn VB.NET

'Declare a BarTender application variable

Dim btApp As BarTender.Application

'Declare a BarTender document variable

Dim btFormat1 As BarTender.Format

Dim btFormat2 As BarTender.Format

'Create a new instance of BarTender

btApp = New BarTender.Application

'Open a BarTender document

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

'Open a BarTender document

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

'Set focus to the first opened document

btFormat1.Activate()

'End the BarTender process

btApp.Quit(BarTender.BtSaveOptions.btDoNotSaveChanges)

ClosedIn C#

// Declare a BarTender application variable

BarTender.Application btApp;

// Declare two BarTender document variables

BarTender.Format btFormat1;

BarTender.Format btFormat2;

// Create a new instance of BarTender

btApp = new BarTender.Application();

// Set the BarTender application visible

btApp.Visible = true;

// Open a BarTender document

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

// Open a second BarTender document

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

// Set focus to the first opened document

btFormat1.Activate();

// End the BarTender process

btApp.Quit(BarTender.BtSaveOptions.btDoNotSaveChanges);

Related Topics