CreateNewLib Method

Creates a new library and makes it active. Returns an instance of the Library object, corresponding to the created library.

Applies to: Application object

Syntax

[[Set] libraryRet =] object.CreateNewLib ()

The CreateNewLib method syntax has these parts:

Part Description
object Required. An expression that returns an instance of the Application object.
libraryRet Optional. A Library type variable.

Remarks

A new library created with the CreateNewLib method becomes active and is added to the current library window. Note, that the new library is added to the end of the library collection of the document. That is, the following expression will return an instance of the Library object corresponding to the most recent created or open library:

thisApp.Lib( thisApp.LibsNum() )

Example

This example contains an application-level script. The script creates a library and adds three shapes into it: a square, a circle and a triangle. The shapes are drawn in a temporary document, which is then closed without saving. The new library is saved in the current folder.

Dim newLib As Library           ' Declare variables
Dim tmpDoc As Document
Dim workPage As Page

Set newLib = thisApp.CreateNewLib()                ' Create new library
newLib.Title= "Simple_Items"                       ' Choose  title 
newLib.Name = "Simple_Items.cdl"                   ' and filename

Set tmpDoc = thisApp.CreateNewDoc()                ' Create temporary document
Set workPage = tmpDoc.Page(1)                      ' Get reference to the document page
workPage.DrawRect(0, 0, 400, 400).Text = "Square"  ' Draw square
workPage.DrawOval(0, 0, 400, 400).Text = "Circle"  ' Draw rectangle
workPage.BeginShape()                              ' Draw triangle
workPage.MoveTo(0, 400)
workPage.LineTo(400, 400)
workPage.LineTo(200, 400 - 400*cos(3.1419/6) )
workPage.LineTo(0, 400)
workPage.EndShape().Text = "Triangle"

For i=1 to 3                                  ' Add the figures 
newLib.AddMaster( workPage.Shape(i) ) ' to newLib library Next i thisApp.CloseDoc( tmpDoc ) ' Close document without saving newLib.Save() ' Save library in current folder

 

See Also

CloseLib method, CreateNewLib method, FindLib method, Lib method, LibByName method, LibsNum method, OpenLib method, Library object