Using the Format Object |
The Format object represents a BarTender document (with the extension *.btw). Format objects are opened in an instance of the BarTender application, giving access to a wide range of BarTender functionality. When using the Format object, developers can easily open, save, and print document, as well as change database options and modify text and barcode data.
The Format object allows you to manipulate existing documents by changing print settings and accessing object properties. It does not allow you to modify the layout of templates in a document or to create new documents.
The Application object contains a list of all documents currently open in BarTender, accessed through the Application object's Formats collection object. This collection object also provides a way to open, close, and save BarTender documents.
A BarTender document is opened by calling the Formats collection object's Open method. This method returns a Format object, representing the document that was just opened. The Formats.Open method has three arguments. The first argument is required and specifies 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.
The following code demonstrates how to open a BarTender document.
Closing a BarTender document is achieved by calling the Format.Close method. The following code provides an example of how to close a document.
The Format.Close method takes a BtSaveOptions parameter. This allows the user to choose whether to save, prompt for save, or discard changes made to the document.
Once a Format object is no longer in use by your client application, the Format.Close method should be called. Failure to do so unnecessarily leaves a document open in BarTender and consumes resources.
Related Topics