You are on page 1of 319

Automate Impromptu Using Macros

While every attempt has been made to ensure that the information in this document is accurate and complete, some typographical errors or technical inaccuracies may exist. Cognos does not accept responsibility for any kind of loss resulting from the use of information contained in this document. This page shows the publication date. The information contained in this document is subject to change without notice. Any improvements or changes to either the product or the document will be documented in subsequent editions. This text contains proprietary information which is protected by copyright. All rights are reserved. No part of this document may be photocopied, reproduced, stored in a retrieval system, transmitted in any form or by any means, or translated into another language without the prior written consent of Cognos Incorporated. U.S. Government Restricted Rights. The software and accompanying materials are provided with Restricted Rights. Use, duplication for disclosure by the Government is subject to the restrictions in subparagraph (c)(1)(ii) of the Rights in Technical Data and Computer Software clause at DFARS 252.227-7013, or subparagraphs (c) (1) and (2) of the Commercial Computer Software - Restricted Rights at 48CFR52.227-19, as applicable. The Contractor is Cognos Corporation, 67 South Bedford Street, Burlington, MA 01803-5164.

Impromptu version 5.0

This edition published 1998. Copyright 1998, Cognos Incorporated Portions Copyright Microsoft Corporation, One Microsoft Way, Redmond, Washington 98052-6399 USA. All rights reserved. Portions of this product provided by LEAD Technologies, Inc. Charlotte, NC. Portions Copyright LEAD Technologies, Inc. 1991-1995. ALL RIGHTS RESERVED Portions Copyright Gupta Corporation Portions Copyright Syware, Inc. Cognos, the Cognos logo, the Cognos tag line "Better Decisions Every Day," Impromptu, PowerPlay, PowerCube, Scenario, 4Thought, DataMerchant, PowerHouse, RealObjects, COGNOSuite, and Cognos Accelerator are trademarks of Cognos Incorporated. All other trademarks mentioned are the property of their respective owners.

Table of Contents
Chapter 1: Run a Macro in Impromptu....................... 5 Chapter 2: Introduction to Impromptu OLE Automation ................................................... 9 Chapter 3: Application Automation ......................... 13 Chapter 4: Catalog Automation ............................... 17 Chapter 5: Expression Automation .......................... 61 Chapter 6: Report Automation................................. 67 Chapter 7: Stored Procedures Automation ............... 77 Chapter 8: Methods ................................................ 81 Chapter 9: Impromptu Properties .......................... 201 Index .................................................................... 311

Automate Impromptu Using Macros iii

Chapter 1: Run a Macro in Impromptu

Automate Impromptu Using Macros 5

Chapter 1: Run a Macro in Impromptu

Run a Macro in Impromptu Using a Command or Toolbar Button


In Impromptu, you can run your macro directly from the Macro command (Tools menu), or you can program a Launch button in Impromptu that you use frequently for easy access to a macro.
Steps to Run a Macro Using a Command

1. From the Tools menu, click Macro. 2. Select the macro file to run. 3
s

Click Run. Set up a Launch button to run a macro using the Toolbars selection of the Tools menu. (For more information, see Set Up a Launch Button in the Mastering Impromptu Reports PDF book.) To distinguish between multiple Launch buttons, use different icons.

Step to Run a Macro Using a Toolbar Button

Tip

Run a Macro in Impromptu at Startup


You can set Impromptu to run a macro every time it starts to customize the application.
Example

You can create a macro that shows a list of the five most frequently used reports every time you start Impromptu. 1. From the Tools menu, click Options. 2. Click the General tab. 3 4
Tip

Select the Run option button. Browse for the file and click OK to return to the Options dialog box or type the file name in the Run box, and click OK. To skip the macro that normally executes as Impromptu starts, hold down the Ctrl key when Impromptu is starting.

6 Automate Impromptu Using Macros

Chapter 1: Run a Macro in Impromptu

Run a Macro in Impromptu Using a Command Line Option


You can run a macro in Impromptu from the command line using the -m option. 1. In the task bar, click Start, and click Run. 2. Browse for the file and click OK to return to the Run dialog box or type the fully qualified file name in the Open or Run box. 3 Type - m with the fully qualified file name of the macro, and click OK.

Run a Macro in Impromptu Before Opening a Report


You can set Impromptu to run a macro before you open a report. Impromptu runs the macro after the data is retrieved. 1. From the Report menu, click General. 2. Click the Macro tab. 3. Browse for the file and click OK to return to the Properties dialog box, or type the file name in the Perform When Opening Report box, and click OK.
Tip

To run the macro before data is retrieved, disable auto-retrieve using the Retrieve command (Report menu).

Automate Impromptu Using Macros 7

Chapter 2: Introduction to Impromptu OLE Automation

Automate Impromptu Using Macros 9

Chapter 2: Introduction to Impromptu OLE Automation

Introduction to Impromptu OLE Automation


Description

Impromptu uses OLE automation to expose the following objects: An Application object that you can use to invoke Impromptu from within macros and automation procedures in other OLE 2.0 applications. A Report Document object that you can use to operate on and control the properties of an Impromptu report that is invoked using OLE automation. A PublishHTML object that you can use to publish your report in Hyper Text Markup Language format. An Expression object that you can use to add expressions to your catalogs or your reports. A Stored Procedure object that you can use to execute database stored procedures from within an OLE automation script. A SelectedFrame object represents an individual frame on a Report Document that has been selected by a user. Numerous catalog automation objects that you can use to create and operate on catalogs. Within the hierarchy for OLE automation objects, you can create Report Document objects, within the context of an empty Application object, to reference existing reports. You can create Stored Procedure objects for Application objects. You can create PublishHTML objects within Report Document objects. You can create SelectedFrame objects within Report Document objects. You can create a Catalog object within the Application object and you can create and modify Expression objects within Catalog objects.

10 Automate Impromptu Using Macros

Chapter 2: Introduction to Impromptu OLE Automation


Catalog OLE Automation

Impromptu uses OLE automation to expose numerous objects to operate on catalogs. The objects include the following: A Catalog object that you can use to manipulate catalogs. A Database object that you can use to set up the database for your catalog, and a Databases collection to group Database objects, although, presently you can only have one Database in the collection. A CatalogLevel object that you can use to insert a database qualification level, and a CatalogLevels collection to group CatalogLevel objects. A SchemaLevel object that you can use to insert a different database qualification level, and a SchemaLevels collection to group SchemaLevel objects. A Table object that you can use to operate on tables in a database, and a Tables collection to group Table objects. A Column object that you can use to operate on the individual columns in a database table, and a Columns collection to group Column objects. A TableLink object that you can use to join tables, and a TableLinks collection to group TableLink objects. A FolderItem object that you can use to organize your catalog, a Folders collection to group FolderItem objects, and an Items collection to group Expression objects in a FolderItem object. A UserClass object that you can use to set security for your catalog, and a UserClasses collection to group UserClass object. A series of collections that reference objects from other collections to indicate whether a certain condition exists. These collections include DeniedTables, DeniedColumns, DeniedSchema, DeniedCatalogs, DeniedFolderItems, FilteredTables, and FilteredColumns

Automate Impromptu Using Macros 11

Chapter 2: Introduction to Impromptu OLE Automation


Tips for Writing Efficient Impromptu Macros

Where possible, limit the number of calls you make to Application Automation methods when you write Catalog Automation macros. For example, instead of using app.ActiveCatalog for every reference to the current catalog in a Catalog Automation macro, call the ActiveCatalog method once, set the object variable to the Catalog object, and use the Catalog object variable in subsequent calls. Before you re-use an object variable that has already been used as an argument in a method call, release the associated object explicitly by setting the object variable to "Nothing". When releasing associated objects from variables, remember to release contained objects before their container objects. For example, release the Column object before the Table object. Consider splitting long chains of property calls, like the following, into parts having one or two method calls each:
cat.Databases(1).CatalogLevels(1).SchemaLevels(1).Tables(1).Columns(1).Name

For this, declare and use separate object variables for the database, qualification levels, tables, and columns.

12 Automate Impromptu Using Macros

Chapter 3: Application Automation

Automate Impromptu Using Macros 13

Chapter 3: Application Automation

Application Object
Description

An Impromptu application creates, opens and operates on catalogs, templates, and reports.
Discussion

Use an Application object to start Impromptu from within an OLE automation script. You can declare an object variable and then use the CreateObject method to create an Impromptu application object.
Example

The following script creates an Impromptu Application object from an existing report. The first two lines use the Dim statement to declare two object variables. The first two lines in the Main subroutine assign values to these object variables using the CreateObject statement and the OpenReport method. The rest of the macro prints a copy of pages 1 through 4, closes the report, quits Impromptu, and finally frees up the resources allocated for the OLE objects.
Dim ImpApp as Object Dim ImpRep as Object Sub Main() Set ImpApp = CreateObject("Impromptu.Application") Set ImpRep = ImpApp.OpenReport("c:\sales\fy93tot.imr") ImpRep.RetrieveAll ImpRep.Print 1,4,1 ImpRep.CloseReport ImpApp.Quit Set ImpRep = Nothing Set ImpApp = Nothing End Sub

Method Name

Description

Activate AddTable CatalogName CatalogOpened ChangeUserClass CloseCatalog CreateCatalog

Activates the window associated with the specified report. Adds a table from the database to the catalog for the current application. Returns the name of the catalog for the specified application. Returns a Boolean value based on whether the application has a catalog open. Changes the current user class. Closes the currently open catalog. Creates a catalog with the default included tables and the default user profile.

14 Automate Impromptu Using Macros

Chapter 3: Application Automation


Method Name Description

CreateEmptyCatalog ConnectDatabase CreateStoredProcedure DatabaseConnected

Creates a new, empty catalog. Attaches to the database for the specified catalog. Creates a Stored Procedure object. Returns a Boolean value based on whether the application has successfully connected to the catalogs database. Disconnects from the database for the specified catalog. Sets the default printer. Generates a report for a specified table. Returns version information for Impromptu applications. Returns an Impromptu error number. Returns a string containing a query error number and the associated query error description. Selects and loads the specified catalog. Opens the specified report. Opens an existing Impromptu report for access by another application or report. Exits Impromptu. Updates the active catalog with information from another catalog.

DisconnectDatabase FileSetPrinter GenerateReport GetAppVersionInfo GetErrorNumber GetNextQueryError

OpenCatalog OpenReport OpenDrillDownReport Quit UpdateCatalog

Automate Impromptu Using Macros 15

Chapter 3: Application Automation

Property Name

Description

ActiveCatalog DatabaseDefinitions ActiveDocument Application FullName Interactive Name OpenDrillDownReport UseQueryWarnings Visible

The active catalog object. An ownership collection of defined databases. Returns the active document. Returns the application object. Returns the full name of the application, including the path. Sets or returns whether the application accepts interactive commands from a user. Returns the name of the application. Opens an existing Impromptu report for access by another application or report. Sets whether Impromptu ignores governor restriction warnings when executing a query. Sets or returns whether the application window is visible.

16 Automate Impromptu Using Macros

Chapter 4: Catalog Automation

Automate Impromptu Using Macros 17

Chapter 4: Catalog Automation

Catalog Object
Description

An object representing the Impromptu catalog.


Discussion

The Catalog object is also known as the active catalog. Only one catalog can be open at a time. If you attempt to open more than one catalog, the open operation will fail
Example

This macro opens a Catalog, makes it non-distributed and displays its filename and description. The first four lines use the Dim statement to declare two object variables and two string variables. The application object is created and a catalog is opened. This catalog is made the active catalog. The catalog is set to be non-distributed, and its filename is read into fname and displayed in a message box. Next, the description of the catalog is read into the desc variable and displayed in a message box. The last two lines of the macro free up the resources allocated for the OLE objects. Note: You must use a valid path and filename for the OpenCatalog method to run this macro. Also, any user classes except the Creator must be removed before a distributed catalog can be made non-distributed.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim fname As String Dim desc As String Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "c:\Catalogs\sample.cat", "Creator" Set ImpCat = ImpApp.ActiveCatalog ImpCat.IsDistributed = False fname = ImpCat.Filename MsgBox "The filename of the Catalog is " & fname desc = ImpCat.Description MsgBox "The Catalog Description is " & desc Set ImpCat = Nothing Set ImpApp = Nothing End Sub .

18 Automate Impromptu Using Macros

Chapter 4: Catalog Automation


CatalogLevel Object

Method Name

Description

Close DistributedUpdate Save

Closes the Catalog. Performs Catalog update against the master Catalog. Saves the current Catalog to disk under the filename found in its Filename property.
Description

Property Name

ActiveUserClass Application Databases Description Filename Folders IsDistributed MasterCatalogFilename Parent TableLinks
Description

Returns the active user class. Returns the Application object. Returns a collection of Database objects. Sets or returns a text description of the catalog. Returns the name of the file for the catalog. Returns the top-level Items collection in a catalog. Sets or returns whether a catalog is distributed or not. Returns the filename for the master catalog. Returns the parent object. Returns a collection of TableLink objects.

An object that represents the catalog qualification level of a Database object.


Discussion

Depending on the qualification levels of the Database object containing the CatalogLevel object, the CatalogLevel object can contain a collection of Table objects or a collection of SchemaLevel objects that contain collections of Table objects. A CatalogLevel represents one level of qualification in the parent Database object. For a CatalogLevel object that contains SchemaLevel objects, there are two levels of qualification in the parent Database object. To access a Table object, its location must be correctly qualified.

Automate Impromptu Using Macros 19

Chapter 4: Catalog Automation To see if the catalog representation of the database uses the database catalog and/or database schema qualification levels to qualify tables, use the following conditional statement:
Check for the database catalog qualification first: IF Not (database.CatalogLevels Is Nothing) THEN The database uses the database catalogs to qualify other database objects (schemata or tables). [ more of your code ] Remember: for each CatalogLevel object you will need to check for the database schema qualification it may be using. ELSE The database does not use the database catalogs, check for the database schema qualification: IF Not (database.SchemaLevels Is Nothing) THEN The database uses the database schemata to qualify tables. [ more of your code ] ELSE The database does not use any qualification levels for tables. [ more of your code ] END IF END IF

20 Automate Impromptu Using Macros

Chapter 4: Catalog Automation


Example

The following example opens a catalog, sets the database for the catalog, displays the name of the CatalogLevel object, and then releases the resources allocated to the objects. Note: This code sample will not run unless the catalog used contains qualification levels. The Outdoors catalog does not contain qualification levels.
Sub Main() Dim DB As Object Dim ImpApp As Object Dim ImpCat As Object Dim CatLevel As Object Dim CatLevelName As String Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\Catalogs\Sample.cat", "creator" Set ImpCat = ImpApp.ActiveCatalog Set DB = ImpCat.Databases("OUTDOORS") Set CatLevel = DB.CatalogLevels(1) CatLevelName = CatLevel.Name MsgBox CatLevelName Set CatLevel = Nothing Set DB = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

Method Name

Description

Delete

Deletes the CatalogLevel object from the CatalogLevels collection.


Description

Property Name

Application Name Parent SchemaLevels Tables

Returns the Application object. Returns the name of the CatalogLevel object. Returns the parent object. Returns a collection of SchemaLevel objects. Returns a collection of Table objects.

Automate Impromptu Using Macros 21

Chapter 4: Catalog Automation

Column Object
Description

An object that represents a column in a Table object.


Discussion

Each Column object corresponds to a column in a table. Column objects are grouped in the Columns collection which is owned by Table objects
Example

The following example opens an existing catalog, sets the Column object from the database table COUNTRY and column COUNTRY_CD, and displays the name of the Column object. Before ending, the macro releases the resources allocated to the object variables.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim DB As Object Dim ColObj As Object Dim ColName As String Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\Catalogs\Sample.cat" Set ImpCat = ImpApp.ActiveCatalog Set DB = ImpCat.Databases(1) Set ColObj = DB.Tables("COUNTRY").Columns("COUNTRY_CD") ColName = ColObj.Name MsgBox ColName Set ColObj = Nothing Set DB = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub .

Method Name

Description

Delete

Deletes the Column object from the Columns collection.


Description

Property Name

Application IsKey Name Parent Type

Returns the Application object. Sets or returns whether the Column object is a key. Returns the name of the Column object. Returns the parent object. Sets or returns the data type of the Column object.

22 Automate Impromptu Using Macros

Chapter 4: Catalog Automation

Database Object
Description

An object that represents the Impromptu view of the database. A Database object ultimately contains Table objects. Some Database objects are organized with one or two levels of qualification for Tables. These levels of qualification are CatalogLevel and SchemaLevel. SchemaLevel objects contain Table objects and CatalogLevel objects contain SchemaLevel objects.
Discussion

A Database object can be structured in four ways: Database object containing Table objects (no qualification) Database object containing SchemaLevel objects that contain Table objects (one level of qualification) Database object containing CatalogLevel objects that contain Table objects (one level of qualification) Database object containing CatalogLevel objects that contain SchemaLevel objects that contain Table object (two levels of qualification) For a Database object with no qualification levels, the Tables in the collection can be accessed by name because all Table object names are unique. For Database objects with qualification levels, the Table object names are not necessarily unique and therefore an error can occur if you attempt to access a Table object by name from the Database object. This is also true for aliases created for the Table object and SchemaLevel objects where the Database object contains two levels of qualification

Automate Impromptu Using Macros 23

Chapter 4: Catalog Automation


Example

The following example: creates a new catalog, sets the Database object, inserts two qualification levels, adds a second CatalogLevel object, adds two SchemaLevel objects to the second CatalogLevel object, and adds a second SchemaLevel object to the first CatalogLevel object. The catalog is saved and the resources allocated to the objects are released.
Option Explicit Sub Main() Dim DB As Object Dim ImpApp As Object Dim ImpCat As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.CreateCatalog "C:\Catalogs\Sample.cat", "OUTDOORS", 0 Set ImpCat = ImpApp.ActiveCatalog Set DB = ImpCat.Databases("OUTDOORS") DB.InsertQualificationLevel "Schema 1a", 1 DB.InsertQualificationLevel "Catalog 1", 0 DB.CatalogLevels.Add "Catalog 2" DB.CatalogLevels(2).SchemaLevels.Add "Schema 2a" DB.CatalogLevels(2).SchemaLevels.Add "Schema 2b" DB.CatalogLevels(1).SchemaLevels.Add "Schema 1b" ImpCat.Save Set DB = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub .

24 Automate Impromptu Using Macros

Chapter 4: Catalog Automation

Method Name

Description

Delete InsertQualificationLevel RemoveQualificationLevel

Deletes the Database object from the Databases collection. Attempts to insert a database qualification level into an existing Database object. Removes the qualification level immediately below the Database object.
Description

Property Name

Application CatalogLevels Name Parent SchemaLevels Tables

Returns the Application object. Returns a collection of CatalogLevel objects. Returns the name of the Database object. Returns the parent object. Returns a collection of SchemaLevel objects. Returns a collection of Table objects.

Automate Impromptu Using Macros 25

Chapter 4: Catalog Automation

DatabaseConnection Object
Description

An object that describes the user classs connection information for a database.
Discussion

The collection of DatabaseConnections is a property of the UserClass object.


Example

This macro returns the username for the first DatabaseConnection object in the collection. Four object variables are declared. The application object is created and assigned to the ImpApp variable. A catalog is opened, made the active catalog, and assigned to the ImpCat variable. The first object in the DatabaseConnections collection is assigned to the dbConnectObj variable. The name of the DatabaseConnection is shown in a message box. Before ending, the macro releases the resources allocated to the four objects.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim dbConnectObj As Object Dim User As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "c:\Imp_cat\biadmin.cat", _ "Creator",,"biadmin","biadmin" Set ImpCat = ImpApp.ActiveCatalog Set User = ImpCat.ActiveUserClass Set dbConnectObj = User.DatabaseConnections(1) MsgBox dbConnectObj.UserName Set dbConnectObj = Nothing Set User = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

26 Automate Impromptu Using Macros

Chapter 4: Catalog Automation

Property Name

Description

Application DBObject EncryptedPassword Parent PlainTextPassword ReadIsolationLevel

Returns the Application object. Returns the Database object associated with the connection. Sets or returns the encrypted password for the Database object. Returns the parent object. Sets the unencrypted password for the Database object. Sets or returns the read-transaction isolation level to request when connecting to the Database object. Sets or returns the name used to log onto the Database object.

UserName

Automate Impromptu Using Macros 27

Chapter 4: Catalog Automation

DatabaseDefinition Object
Description

An object representing the defined databases for Impromptu.


Discussion

This object corresponds to the .ini file entries and values from the Database Definition dialog boxes
Example

This macro returns the name of the first DatabaseDefinition object. Two object variables are declared. The application object is created and assigned to the ImpApp variable. The first DatabaseDefinition in the DatabaseDefinitions collection is assigned to the dbDefinition variable. The name of the DatabaseDefinition is shown in a message box, then the resources for the object variables are released.
Sub Main() Dim ImpApp As Object Dim dbDefinition As Object Set ImpApp = CreateObject("Impromptu.Application") Set dbDefinition = ImpApp.DatabaseDefinitions(1) MsgBox dbDefinition.Name Set dbDefinition = Nothing Set ImpApp = Nothing End Sub .

Property Name

Description

Application Definition Name Parent

Returns the Application object. Returns the database connection string from the Cognos.ini file. Returns the logical database name. Returns the parent object.

28 Automate Impromptu Using Macros

Chapter 4: Catalog Automation

FolderItem Object
Description

An Impromptu folder item.


Discussion

Use the FolderItem object and its properties and methods to define the business view of your organization for your users. Folder items can be one of two things: a folder (in which case it may have child items) an expression The default property for FolderItem is Value
Example

This macro returns the name of the first folder item in the Catalog. Three object variables are declared. The application object is created and assigned to the ImpApp variable. A catalog is opened, made the active catalog, and assigned to the ImpCat variable. The first folder item in the Folders collection is assigned to the FoldItem variable. Its name is shown in a message box and then the resources allocated to the object variables are released.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim FoldItem As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\temp\test.cat", "Creator" Set ImpCat = ImpApp.ActiveCatalog Set FoldItem = ImpCat.Folders(1) MsgBox "The first folder is " & FoldItem.Name Set FoldItem = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub .

Automate Impromptu Using Macros 29

Chapter 4: Catalog Automation

Method Name

Description

CopyTo Delete MoveTo

Copies the folder to the destination folder. Deletes the item from the ownership collection. Moves the folder to the destination folder (the equivalent of a cut and paste).
Description

Property Name

Application Items Name Parent Value

Returns the Application object. Returns a collection of children FolderItem objects. Returns the name of the FolderItem object. Returns the parent object. Returns the expression in the FolderItem object.

30 Automate Impromptu Using Macros

Chapter 4: Catalog Automation

SchemaLevel Object
Description

An object that represents the schema qualification level of a Database object. A SchemaLevel object contains Table objects.
Discussion

A SchemaLevel object can have as the parent object, a Database object, or a CatalogLevel object. To see if the catalog representation of the database uses the database catalog and/or database schema qualification levels to qualify tables, use the following conditional statement:
Check for the database catalog qualification first: IF Not (database.CatalogLevels Is Nothing) THEN The database uses the database catalogs to qualify other database objects (schemata or tables). [ more of your code ] Remember: for each CatalogLevel object you will need to check for the database schema qualification it may be using. ELSE The database does not use the database catalogs, check for the database schema qualification: IF Not (database.SchemaLevels Is Nothing) THEN The database uses the database schemata to qualify tables. [ more of your code ] ELSE The database does not use any qualification levels for tables. [ more of your code ] END IF END IF

Automate Impromptu Using Macros 31

Chapter 4: Catalog Automation


Example

The following example: creates a new catalog, sets the database, sets the schema qualification level, displays the name of the SchemaLevel object, and sets all objects to nothing.
Option Explicit Sub Main() Dim DB As Object Dim ImpApp As Object Dim ImpCat As Object Dim SchLevel As Object Dim SchName As String Set ImpApp = CreateObject("Impromptu.Application") ImpApp.CreateCatalog "C:\Catalogs\Sample.cat", "OUTDOORS", 0 Set ImpCat = ImpApp.ActiveCatalog Set DB = ImpCat.Databases("OUTDOORS") Set SchLevel = DB.SchemaLevels(1) SchName = SchLevel.Name MsgBox SchName Set SchLevel = Nothing Set DB = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

Method Name

Description

Delete

Deletes the SchemaLevel object from the SchemaLevels collection.


Description

Property Name

Application Name Parent Tables

Returns the Application object. Returns the name of the SchemaLevel object. Returns the parent object. Returns a collection of Table objects.

32 Automate Impromptu Using Macros

Chapter 4: Catalog Automation

Table Object
Description

An object that represents the Impromptu view of a database table. A Table object contains Column objects.
Discussion

For a Table object, its parent object can be a Database object, a CatalogLevel object, or a SchemaLevel object, depending on the qualification levels of the Database object. When the parent of a Table object is a CatalogLevel object, the Database object associated cannot access the Table object directly through its Tables collection, as it is not directly linked to the Table object. The same situation occurs when the parent of the Table object is a SchemaLevel object
Example

The following example: opens an existing catalog, sets the database, sets the table, displays the name of the Table object, and sets all objects to nothing.
Option Explicit Sub Main() Dim DB As Object Dim ImpApp As Object Dim ImpCat As Object Dim oTable As Object Dim TableName As String Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\Catalogs\Sample.cat", "Creator" Set ImpCat = ImpApp.ActiveCatalog Set DB = ImpCat.Databases("OUTDOORS") Set oTable = DB.Tables(1) TableName = oTable.Name MsgBox TableName Set oTable = Nothing Set DB = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub .

Automate Impromptu Using Macros 33

Chapter 4: Catalog Automation

Method Name

Description

CreateAlias Delete

Creates an alternate name of the Table object. Deletes the Table object from the Tables collection.
Description

Property Name

Application Columns MasterTable Name Parent

Returns the Application object. Returns a collection of Column objects. Returns the original Table object of this Table object, if this Table object is an alias. Returns the name of the Table object. Returns the parent object.

34 Automate Impromptu Using Macros

Chapter 4: Catalog Automation

TableLink Object
Description

A single-step link between two Table objects.


Discussion

Joins (table links) are composed of a left and right table, and a condition. The condition is an Expression object
Example

This macro returns the numeric join type of the first TableLink Object. Three object variables are declared. The application object is created and assigned to the ImpApp variable. The active catalog is assigned to the ImpCat variable. The first TableLink object in the TableLinks collection is assigned to the TabLinkObj variable. The type of link for this object is then displayed. Note: The Type property will return numbers which correspond to a string.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim TabLinkObj As Object Set ImpApp = CreateObject("Impromptu.Application") Set ImpCat = ImpApp.ActiveCatalog Set TabLinkObj = ImpCat.TableLinks(1) MsgBox "The first link is an " & TabLinkObj.Type End Sub .

Method Name

Description

Delete

Deletes the TableLink object from the TableLinks collection.


Description

Property Name

Application Condition LeftTable Parent RightTable Type

Returns the Application object. Returns the join expression. Sets or returns the "left" table in the join. Returns the parent object. Sets or returns the "right" table in the join. Returns the type of join.

Automate Impromptu Using Macros 35

Chapter 4: Catalog Automation

UserClass Object
Description

An object that represents a user profile.


Discussion

Use this object to define query restrictions, security levels, filters, and other permissions for Impromptu user classes.
Example

The following example returns the name of the first UserClass object under the Creator UserClass object.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim User As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\temp\outtest1.cat" Set ImpCat = ImpApp.ActiveCatalog Set User = ImpCat.ActiveUserClass.UserClasses(1) MsgBox User.Name Set User = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

Method Name

Description

CreateFilterFor

Creates a new filter for the specified object and returns the filter for further modification. Deletes the UserClass object from the UserClasses collection. Returns the filter expression, if one exists, for the specified object. Removes a filter for the specified object.
Description

Delete GetFilterFor RemoveFilterFor


Property Name

Application CanAddOrModifyFolders CanAddOrModifyUserClasses

Returns the Application object. Sets or returns whether the UserClass object can add or modify folders. Sets or returns whether the UserClass object can add or modify user classes.

36 Automate Impromptu Using Macros

Chapter 4: Catalog Automation


Property Name Description

CanCreateNewReports CanDirectEnterSQL CrossProductPermission DatabaseConnections

Sets or returns whether the UserClass object can create new reports. Sets or returns whether the UserClass object can enter SQL queries. Sets or returns whether the UserClass object has cross-product permission. Returns a collection of DatabaseConnection objects for the UserClass object. Returns a collection of CatalogLevel objects to which the UserClass object is denied access. Returns a collection of Column objects to which the UserClass object is denied access. Returns a collection of FolderItem objects to which the UserClass object is denied access. Returns a collection of SchemaLevel objects to which the UserClass object is denied access. Returns a collection of Table objects to which the UserClass object denied access. The password for logging onto the database. Returns a collection of Column objects for which the UserClass object has filters. Returns a collection of Table objects for which the UserClass object has filters. Sets or returns whether the UserClass object has a text-blob limit. Sets or returns the time limit to run a query for the UserClass object. Sets or returns the maximum number of rows the UserClass object can retrieve.

DeniedCatalogs

DeniedColumns

DeniedFolderItems

DeniedSchemas

DeniedTables

EncryptedPassword FilteredColumns

FilteredTables

HasTextBlobLimit MaxQueryExecutionTime MaxRowsRetrieved

Automate Impromptu Using Macros 37

Chapter 4: Catalog Automation


Property Name Description

MaxTablesPerReport

Sets or returns the maximum number of tables the UserClass object can retrieve. Sets or returns the maximum number of text-blob characters for the UserClass object. Sets or returns whether the connect time is minimized. Sets or returns the name of the UserClass object Sets or returns whether the UserClass object can sort non-indexed columns. Sets or returns the outer join permission for the UserClass object. Returns the parent object. The plain-text password for logging onto the database. Sets or returns the time for the query execution at which the UserClass object is warned. Sets or returns the state of query processing for the UserClass object. Sets or returns the number of rows retrieved at which the UserClass object is warned. Sets or returns whether the user can set the query to select distinct values in a database. Sets or returns the number of tables used per report at which the UserClass object is warned. Returns a collection of UserClass objects based on this UserClass object.

MaxTextBlobCharacters

MinimizeConnectTime Name NonIndexSortingPermission OuterJoinPermission Parent PlainTextPassword QueryExecutionTimeWarnAfter

QueryProcessing RowsRetrievedWarnAfter

SelectDistinctPermission

TablesPerReportWarnAfter

UserClasses

38 Automate Impromptu Using Macros

Chapter 4: Catalog Automation

CatalogLevels Collection
Description

An ownership collection of CatalogLevel objects.


Discussion

Only Database objects can contain a CatalogLevels Collection. A Database object only contains a CatalogLevels collection if the Database object supports a catalog qualification level. If a Database object does not support catalog qualification, attempts to access a specific CatalogLevel object from the CatalogLevels collection will fail
Example

The following macro adds a CatalogLevel object to the CatalogLevels collection. Three object variables and one string variable are declared. The application object is created and assigned to the ImpApp object. A catalog is created and made the active catalog. The OUTDOORS database is assigned to the DB variable. Before ending, the macro releases the resources allocated to the object variables.
Sub Main() Dim DB As Object Dim ImpApp As Object Dim ImpCat As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.CreateCatalog "C:\Catalogs\Sample.cat", "OUTDOORS", 0 Set ImpCat = ImpApp.ActiveCatalog Set DB = ImpCat.Databases("OUTDOORS") DB.InsertQualificationLevel "Catalog 1", 0 DB.CatalogLevels.Add "Catalog 2" Set DB = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub .

Method Name

Description

Add

Adds a new CatalogLevel object to the CatalogLevels collection.


Description

Property Name

Application Count Item Parent

Returns the Application object. Returns the number of items in the collection. Returns the specified item in the collection. Returns the parent object.

Automate Impromptu Using Macros 39

Chapter 4: Catalog Automation

Columns Collection
Description

An ownership collection of Column objects owned by a Table object.


Discussion

To use this collection, first add a Database object to the Catalog object, and then add the necessary qualification levels using the CatalogLevel object, or the SchemaLevel object. Finally add Column objects to the Columns collection. Use the Item property to select a specific column object in the collection
Example

The following example adds a new column "REGION" of type "Char" to the COUNTRY table and sets it as a key. Three object variables are declared. The application object is created and assigned to the ImpApp object. A catalog is opened and made the active catalog. The first database in the Databases collection is assigned to the DB variable. The REGION column is added to the Columns collection. This column is made a key. Before ending, the macro releases the resources allocated to the object variables.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim DB As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\Catalogs\Sample.cat" Set ImpCat = ImpApp.ActiveCatalog Set DB = ImpCat.Databases(1) DB.Tables("COUNTRY").Columns.Add "REGION",1 Set DB = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub .

Method Name

Description

Add

Adds a new Column object to the Columns collection.


Description

Property Name

Application Count Item Parent

Returns the Application object. Returns the number of items in the collection. Returns the specified item in the collection. Returns the parent object.

40 Automate Impromptu Using Macros

Chapter 4: Catalog Automation

Databases Collection
Description

An ownership collection of Database objects.


Discussion:

The Database objects in the Databases collection are indexed by name. They may be referenced by name or by index. The Databases collection is also a property of the Catalog object. Note: In this release of Impromptu OLE Automation, there can only be one Database object in the Databases collection
Example
The following example counts the number of Database objects in the Collection. Two object variables are declared. The application object is created and assigned to the ImpApp object. A catalog is opened and made the active catalog. The number of databases in the Databases collection for the active catalog is displayed in a message box. Before ending, the macro releases the resources allocated to the object variables. Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim databases As Integer Set ImpApp = CreateObject("Impromptu.Application") Set ImpCat = ImpApp.ActiveCatalog databases = ImpCat.Databases.count msgbox "There are " & databases & " databases." Set ImpCat = Nothing Set ImpApp = Nothing End Sub .

Method Name

Description

Add

Adds a new Databases object to the Databases collection.


Description

Property Name

Application Count Item Parent

Returns the Application object. Returns the number of items in the collection. Returns the specified item in the collection. Returns the parent object.

Automate Impromptu Using Macros 41

Chapter 4: Catalog Automation

DatabaseConnections Collection
Description

An ownership collection of DatabaseConnection objects for the UserClass object.


Discussion

DatabaseConnections are objects that contain information about a user class's connection for a database. The items in the collection are indexed by name. They may be referenced by name or by index. The DatabaseConnections collection is also a property of the UserClass object. Note: In this release of Impromptu OLE Automation, there can only be one DatabaseConnection object in the DatabaseConnections collection

42 Automate Impromptu Using Macros

Chapter 4: Catalog Automation


Example

The following example counts the number of DatabaseConnection objects in the Collection. Three object variables and one string variable are declared. The application object is created and assigned to the ImpApp object. A catalog is opened and made the active catalog. The OUTDOORS database is assigned to the DB variable. The variable User is assigned the active user class. The number of items in the DatabaseConnections collection for the active user class is assigned to the connections string. The number is displayed in a message box. Before ending, the macro releases the resources allocated to the object variables.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim User As Object Dim connections As String Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "c:\Imp_cat\bi admin.cat", _ "Creator",,"biadmin","biadmin" Set ImpCat = ImpApp.ActiveCatalog Set User = ImpCat.ActiveUserClass connections = User.DatabaseConnections.Count msgbox "There are " & connections & " _ DatabaseConnection Objects." Set User = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub .

Property Name

Description

Application Count Item Parent

Returns the Application object. Returns the number of items in the collection. Returns the specified item in the collection. Returns the parent object.

Automate Impromptu Using Macros 43

Chapter 4: Catalog Automation

DatabaseDefinitions Collection
Description

An ownership collection of defined DatabaseDefinition objects.


Discussion:

A DatabaseDefinition in this collection can be referenced by index number or by Name. The DatabaseDefinitions collection is also a property of the Impromptu application object
Example

This macro counts the number of database definition objects in the Collection. The first two lines of the macro declare variables for one object and a string. The application object is created and assigned to the ImpApp variable. Next, the number of items from the DatabaseDefinitions collection is assigned to the numdefns variable and displayed in a message box. Before ending, the macro releases the resources allocated to the object variables.
Sub Main() Dim ImpApp As Object Dim numdefns As Integer Set ImpApp = CreateObject("Impromptu.Application") numdefns = ImpApp.DatabaseDefinitions.Count MsgBox "The number of database definition objects is " & numdefns Set ImpApp = Nothing End Sub .

Method Name

Description

Add

Adds a new Databases object to the Databases collection.


Description

Property Name

Application Count Item Parent

Returns the Application object. Returns the number of items in the collection. Returns the specified item in the collection. Returns the parent object.

44 Automate Impromptu Using Macros

Chapter 4: Catalog Automation

DeniedCatalogs Collection
Description

A reference collection of CatalogLevel objects to which the UserClass object is denied access.
Discussion:

Any CatalogLevel objects that are in the DeniedCatalogs collection for the parent UserClass object are not inherited by the DeniedCatalogs collection of the child UserClass object.
Example

The following example adds a new CatalogLevel object to the DeniedCatalogs collection.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim db as object Dim User As Object Set ImpApp = CreateObject("Impromptu.Application") Set ImpCat = ImpApp.ActiveCatalog Set db = ImpCat.Databases("OUTDOORS") Set User = ImpCat.ActiveUserClass.UserClasses(1) User.DeniedCatalogs.Add db.CatalogLevels(2) Set db = Nothing Set User = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

Method Name

Description

Add Remove

Adds an existing Catalog object to the DeniedCatalogs collection. Removes the specified Catalog object from the DeniedCatalogs collection
Description

Property Name

Application Count Item Parent

Returns the Application object. Returns the number of items in the collection. Returns the specified item in the collection. Returns the parent object.

Automate Impromptu Using Macros 45

Chapter 4: Catalog Automation

DeniedColumns Collection
Description

A reference collection of Column objects to which the UserClass object is denied access.
Discussion:

Any Column objects that are in the DeniedColumns collection for the parent UserClass object are not inherited by the DeniedColumns collection of the child UserClass object.
Example

The following example adds a column to the DeniedColumns collection.


Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim User As Object Dim DB As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\temp\tester.cat" Set ImpCat = ImpApp.ActiveCatalog Set DB = ImpCat.Databases(1) Set User = ImpCat.ActiveUserClass.UserClasses(1) User.DeniedColumns.Add DB.Tables("BRANCH").Columns("BRANCH") Set DB = Nothing Set User = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

Method Name

Description

Add Remove

Adds an existing Column object to the DeniedColumns collection. Removes the specified Columns object from the DeniedColumns collection
Description

Property Name

Application Count Item Parent

Returns the Application object. Returns the number of items in the collection. Returns the specified item in the collection. Returns the parent object.

46 Automate Impromptu Using Macros

Chapter 4: Catalog Automation

DeniedFolderItems Collection
Description

A reference collection of FolderItem objects to which the UserClass object is denied access.
Discussion:

Any FolderItem objects that are in the DeniedFolderItems collection for the parent UserClass object are not inherited by the DeniedFolderItems collection of the child UserClass object
Example

The following example adds a FolderItem object to the DeniedFolderItems collection.


Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim User As Object Dim DB As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\temp\tester.cat" Set ImpCat = ImpApp.ActiveCatalog Set DB = ImpCat.Databases(1) Set User = ImpCat.ActiveUserClass.UserClasses(1) User.DeniedFolderItems.Add ImpCat.Folders("Admin.") Set DB = Nothing Set User = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub .

Method Name

Description

Add Remove

Adds an existing FolderItem object to the DeniedFolderItems collection. Removes the specified FolderItem object from the DeniedFolderItems collection
Description

Property Name

Application Count Item Parent

Returns the Application object. Returns the number of items in the collection. Returns the specified item in the collection. Returns the parent object.

Automate Impromptu Using Macros 47

Chapter 4: Catalog Automation

DeniedSchemas Collection
Description

A reference collection of SchemaLevel objects to which the UserClass object is denied access.
Discussion:

Any SchemaLevel objects that are in the DeniedSchemas collection for the parent UserClass object are not inherited by the DeniedSchemas collection of the child UserClass object
Example

The following example adds a SchemaLevel object to the DeniedSchemas Collection.


Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim db as object Dim User As Object Set ImpApp = CreateObject("Impromptu.Application") Set ImpCat = ImpApp.ActiveCatalog Set db = ImpCat.Databases("OUTDOORS") Set User = ImpCat.ActiveUserClass.UserClasses(1) User.DeniedSchemas.Add db.SchemaLevels("Schema 2") Set db = Nothing Set User = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub .

Method Name

Description

Add Remove

Adds an existing Schema object to the DeniedSchemas collection. Removes the specified Schema object from the DeniedSchemas collection
Description

Property Name

Application Count Item Parent

Returns the Application object. Returns the number of items in the collection. Returns the specified item in the collection. Returns the parent object.

48 Automate Impromptu Using Macros

Chapter 4: Catalog Automation

DeniedSelectValues Collection
Description

A reference collection of FolderItem objects to which the UserClass object is denied permission to perform a select values operation.
Discussion:

Any FolderItem objects that are in the DeniedSelectValues collection for the parent UserClass object are not inherited by the DeniedSelectValues collection of the child UserClass object. By denying the UserClass object the ability to perform a select value operation, the UserClass object can no longer provide a Select Distinct operation against a column. In situations where the column has numerous unique values, this collection prevents the creation of a very long list of values that can cause great delays. Note: If the SelectDistinctPermission property is set to 2 (Prevent), all columns are denied the permission to perform a Select Distinct operation regardless of whether they are FolderItem objects in this collection.

Automate Impromptu Using Macros 49

Chapter 4: Catalog Automation


Example

The following example adds a Column object to the DeniedSelectValues collection and returns the name of the column object.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim User As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\temp\great sample.cat" Set ImpCat = ImpApp.ActiveCatalog Set User = ImpCat.ActiveUserClass.UserClasses(1) User.DeniedSelectValues.Add ImpCat _ .Folders("Customers").Items("Cust No") MsgBox User.DeniedSelectValues(1).Name Set User = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

Method Name

Description

Add Remove

Adds an existing FolderItem object to the DeniedSelectValues collection. Removes the specified FolderItem object from the DeniedSelectValues collection.
Description

Property Name

Application Count Item Parent

Returns the Application object. Returns the number of items in the collection. Returns the specified item in the collection. Returns the parent object.

50 Automate Impromptu Using Macros

Chapter 4: Catalog Automation

DeniedTables Collection
Description

A reference collection of Table objects to which the UserClass object is denied access.
Discussion:

Any Table objects that are in the DeniedTables collection for the parent UserClass object are not inherited by the DeniedTables collection of the child UserClass object.
Example

The following example adds a Table object to the DeniedTables collection.


Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim User As Object Dim DB As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\temp\tester.cat" Set ImpCat = ImpApp.ActiveCatalog Set DB = ImpCat.Databases(1) Set User = ImpCat.ActiveUserClass.UserClasses(1) User.DeniedTables.Add DB.Tables("ORDER") Set DB = Nothing Set User = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

Method Name

Description

Add Remove

Adds an existing Table object to the DeniedTables collection. Removes the specified Table object from the DeniedTables collection
Description

Property Name

Application Count Item Parent

Returns the Application object. Returns the number of items in the collection. Returns the specified item in the collection. Returns the parent object.

Automate Impromptu Using Macros 51

Chapter 4: Catalog Automation

FilteredColumns Collection
Description

A reference collection of Column objects for which the UserClass object has filters.
Discussion:

Any Column objects that are in the FilteredColumns collection for the parent UserClass object are not inherited by the FilteredColumns collection of the child UserClass object. To add objects to this collection, use the CreateFilterFor method. To remove objects from this collection, use the RemoveFilterFor method.
Example

The following example counts the number of filtered Column objects in the FilteredColumns Collection.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim db as object Dim User As Object Set ImpApp = CreateObject("Impromptu.Application") Set ImpCat = ImpApp.ActiveCatalog Set db = ImpCat.Databases("OUTDOORS") Set User = ImpCat.ActiveUserClass.UserClasses(1) MsgBox User.FilteredColumns.Count Set db = Nothing Set User = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

Property Name

Description

Application Count Item Parent

Returns the Application object. Returns the number of items in the collection. Returns the specified item in the collection. Returns the parent object.

52 Automate Impromptu Using Macros

Chapter 4: Catalog Automation

FilteredTables Collection
Description

A reference collection of Table objects for which the UserClass object has filters.
Discussion

Any Table objects that are in the FilteredTables collection for the parent UserClass object are not inherited by the FilteredTables collection of the child UserClass object. To add objects to this collection, use the CreateFilterFor method. To remove objects from this collection, use the RemoveFilterFor method.
Example

The following example counts the number of filtered Table objects in the FilteredTables Collection.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim db as object Dim User As Object Set ImpApp = CreateObject("Impromptu.Application") Set ImpCat = ImpApp.ActiveCatalog Set db = ImpCat.Databases("OUTDOORS") Set User = ImpCat.ActiveUserClass.UserClasses(1) MsgBox User.FilteredTables.Count Set db = Nothing Set User = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

Property Name

Description

Application Count Item Parent

Returns the Application object. Returns the number of items in the collection. Returns the specified item in the collection. Returns the parent object.

Automate Impromptu Using Macros 53

Chapter 4: Catalog Automation

Folders Collection
Description

The top-level ownership collection of FolderItem objects in a Catalog object.


Discussion

The Catalog object is the parent for items in this collection.


Example

This macro adds a new folder. The first three lines of the macro declare variables for three objects. The application object is created and assigned to the ImpApp variable. Next, a catalog is opened and made the active catalog. The catalog is then closed and automatically saved.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim CatFolders As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\Catalogs\GO Sample.cat", "Creator" Set CatFolders = _ ImpCatFolders("Orders").Items.AddFolder("New Item") ImpApp.CloseCatalog End Sub

Method Name

Description

AddFolder AddItem
Property Name

Adds a folder (sub-folder) to another to a folder. Adds an expression to a folder.


Description

Application Count Item Parent

Returns the Application object. Returns the number of items in the collection. Returns the specified item in the collection. Returns the parent object.

54 Automate Impromptu Using Macros

Chapter 4: Catalog Automation

Items Collection
Description

An ownership collection of child FolderItem objects.


Discussion

This is empty for value items, because only folders can have children.
Example

This macro adds a new folder. The first three lines of the macro declare variables for three objects. The application object is created and assigned to the ImpApp variable. Next, a catalog is opened and made the active catalog. The catalog is then closed and automatically saved.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim CatFolders As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\Catalogs\GO Sample.cat", "Creator" Set CatFolders = _ ImpCatFolders("Orders").Items.AddFolder("New Item") ImpApp.CloseCatalog End Sub

Method Name

Description

AddFolder AddItem
Property Name

Adds a folder (sub-folder) to another to a folder. Adds an expression to a folder.


Description

Application Count Item Parent

Returns the Application object. Returns the number of items in the collection. Returns the specified item in the collection. Returns the parent object.

Automate Impromptu Using Macros 55

Chapter 4: Catalog Automation

SchemaLevels Collection
Description

An ownership collection of SchemaLevel objects.


Discussion:

The objects that can contain SchemaLevels Collections are Database objects and CatalogLevel objects. A Database object only contains a SchemaLevels collection if the Database object supports a schema qualification level. Attempts to access SchemaLevel objects will fail if the Database object contains a CatalogLevel collection because the SchemaLevel objects are ambiguous, or if the Database object does not support a schema qualification level.

56 Automate Impromptu Using Macros

Chapter 4: Catalog Automation


Example

The following example adds SchemaLevels to CatalogLevels in a database. Three object variables and one string variable are declared. The application object is created and assigned to the ImpApp object. A catalog is created and made the active catalog. CatalogLevels and SchemaLevels are inserted, then CatalogLevel and SchemaLevel objects are added. Before ending, the macro releases the resources allocated to the object variables.
Sub Main() Dim DB As Object Dim ImpApp As Object Dim ImpCat As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.CreateCatalog "C:\Catalogs\Sample.cat", "OUTDOORS", 0 Set ImpCat = ImpApp.ActiveCatalog Set DB = ImpCat.Databases("OUTDOORS") DB.InsertQualificationLevel "Schema 1a", 1 DB.InsertQualificationLevel "Catalog 1", 0 DB.CatalogLevels.Add "Catalog 2" DB.CatalogLevels(2).SchemaLevels.Add "Schema 2a" DB.CatalogLevels(2).SchemaLevels.Add "Schema 2b" DB.CatalogLevels(1).SchemaLevels.Add "Schema 1b" Set DB = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

Method Name

Description

Add

Adds a new SchemaLevel object to the SchemaLevels collection.


Description

Property Name

Application Count Item Parent

Returns the Application object. Returns the number of items in the collection. Returns the specified item in the collection. Returns the parent object.

Automate Impromptu Using Macros 57

Chapter 4: Catalog Automation

Tables Collection
Description

An ownership collection of Table objects.


Discussion

The objects that can contain Tables Collections are Database objects, CatalogLevel objects, and Table objects. A Database object only contains a Tables collection if the Database object does not support any qualification levels. If the Database object contains a CatalogLevel or SchemaLevel collection, attempts to directly access Table objects will fail because with qualification levels the Table objects are ambiguous.
Example

The following example opens an existing catalog and adds a new table called "New Table." Before ending, the macro releases the resources allocated to the objects.
Option Explicit Sub Main() Dim DB As Object Dim ImpApp As Object Dim ImpCat As Object Dim TableName As String Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\Catalogs\Sample.cat", "Creator" Set ImpCat = ImpApp.ActiveCatalog Set DB = ImpCat.Databases("OUTDOORS") DB.Tables.Add "New Table" Set DB = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

Method Name

Description

Add

Adds a new Table object to the Tables collection.


Description

Property Name

Application Count Item Parent

Returns the Application object. Returns the number of items in the collection. Returns the specified item in the collection. Returns the parent object.

58 Automate Impromptu Using Macros

Chapter 4: Catalog Automation

TableLinks Collection
Description

An ownership collection of TableLink objects.


Discussion:

TableLink objects are the joins you create for tables. The TableLinks collection is also a property of the Catalog object.
Example

This macro creates a join in the active catalog. Five objects are declared. The application object is created, and the open catalog is made active. The first database in the databases collection is assigned to the variable db. A new link between Branch and CustSite is added. The condition (which is an expression) is defined and saved with the Commit method. Note: To run this macro a catalog must be open and you must use valid table names.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim DB As Object Dim NewLink As Object Dim NewLinkExpression As Object Set ImpApp = CreateObject("Impromptu.Application") Set ImpCat = ImpApp.ActiveCatalog Set db = ImpCat.Databases(1) Set NewLink = ImpCat.TableLinks _ .Add (db.Tables("BRANCH"), db.Tables("CUSTSITE")) Set NewLinkExpression = NewLink.Condition With NewLinkExpression .Append db.Tables("BRANCH").Columns("BRANCH_CD") .Append 24 'in Expression Automation, this statment ' means the equals sign, = .Append db.Tables("CUSTSITE").Columns("BRANCH_CD") .Commit End With End Sub

Method Name

Description

Add

Adds a new TableLink object to the TableLinks collection.


Description

Property Name

Application Count Item Parent

Returns the Application object. Returns the number of items in the collection. Returns the specified item in the collection. Returns the parent object.

Automate Impromptu Using Macros 59

Chapter 4: Catalog Automation

UserClasses Collection
Description

An ownership collection of UserClass objects.


Discussion:

All UserClass objects can contain a UserClass collection of UserClass objects. These child UserClass objects inherit the properties of the parent UserClass object and can be further restricted from information in the Catalog object.
Example

The following example adds a new user to the UserClasses collection.


Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim User As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\temp\outtest1.cat" Set ImpCat = ImpApp.ActiveCatalog ImpCat.ActiveUserClass.UserClasses.Add "NewUser" Set User = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

Method Name

Description

Add

Adds a new UserClass object to the UserClasses collection.


Description

Property Name

Application Count Item Parent

Returns the Application object. Returns the number of items in the collection. Returns the specified item in the collection. Returns the parent object.

60 Automate Impromptu Using Macros

Chapter 5: Expression Automation

Automate Impromptu Using Macros 61

Chapter 5: Expression Automation

Expression Object
Description

An object that represents an expression either in a catalog or a report.


Discussion

This object enables the user to change the expression (either as a single operation or by adding elements to an expression one at a time) and query its string representation.
Method Name Description

Append

Appends a single token, an entire expression or the tokens parsed from a string. Empties the expression. Signals that the user has completed all changes using the Append and Clear methods.

Clear Commit

Property Name

Description

Formula ResultType

Contains the string that represents the formula of an expression. Returns an integer value for the type of data resulting from the expression.

Example

This macro adds calculation and condition columns to a catalog. Five object variables are declared. The application object is created and assigned to the ImpApp object. An existing catalog is opened, made the active catalog, and assigned to the ImpCat variable. The folders for the catalog are assigned to the CatFolders variable. The Sale Amount calculation is added to OrdrDetl in the Order folder. The expression is created using a series of Append statements. The Closed Sale folder is added to the Conditions item in the Orders folder. The expression is created using a series of Append statements. Finally, the changes are committed and the catalog is saved.

62 Automate Impromptu Using Macros

Chapter 5: Expression Automation


Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim CatFolders as Object Dim NewColumnExpression As Object Dim NewColumn As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\Catalogs\GO Sample.cat", "Creator" Set ImpCat = ImpApp.ActiveCatalog set CatFolders = ImpCat.Folders 'add calculation column to Order folder Set NewColumn = _ CatFolders("Order").Items("Ordrdetl").Items.AddItem _ ("Sale Amount", 1) Set NewColumnExpression = NewColumn.Value With NewColumnExpression .Append 100 '( .Append 2, 1 'numeric constant 1 .Append 23 '.Append _ CatFolders("Order").Items("Ordrdetl").Items("Disc Prcnt").Value .Append 21 '/ .Append 2, 100 'numeric constant 100 .Append 101 ') .Append 20 '* .Append 100 '( .Append _ CatFolders("Order").Items("Ordrdetl").Items("Price").Value .Append 20 '* .Append _ CatFolders("Order").Items("Ordrdetl").Items("Qty").Value .Append 101 ') .Commit End With 'Add closed sale filter column to the subfolder Conditions Set NewColumn = _ CatFolders("Order").Items("Conditions").Items.AddItem _ ("Closed Sale", 2) Set NewColumnExpression = NewColumn.Value NewColumnExpression.Append _ CatFolders("Order").Items("Closed Dt").Value NewColumnExpression.Append 36 'is not missing NewColumnExpression.Commit ImpCat.Save End Sub

Automate Impromptu Using Macros 63

Chapter 5: Expression Automation

Token Table
Token ID Name Optional Parameters

string constant

Info1: Variant anything that can be evaluated as a string

2 3

numeric constant date constant

Info1: Variant any numeric Info1: Variant a date-time value where the time portion is set to the Visual Basic standard for time (midnight)

time constant

Info1: Variant a date time value where the date portion is set to the VB standard (1997/12/30)

5 6

datetime constant interval constant

Info1: Variant a date time value any numeric value Info1: Variant a string formatted as DD HH:MM:SS.mmm Since dates are stored as 8-byte floats and subtracting two dates will result in a number the interval constant can be represented as a number.

20 21 22 23 24 25 26 27 28

multiply divide plus minus equal greaterthan greaterequal lessthan lessequal

none none none none none none none none none

64 Automate Impromptu Using Macros

Chapter 5: Expression Automation


Token ID Name Optional Parameters

29 30 31 32 33 34 35 36 37 40 44 45 46 47 48 60 61 62 63 64 65 66 67 68 69 70 71 72 73 80 81 82

notequal not or and ismissing startswith contains isnotmissing like between if then else lookup in total minimum maximum average count rank percentile percentage running total running minimum running maximum running average running count stddev for sort by distinct

none none none none none none none none none none none none none none none none none none none none none none none none none none none none none none none none

Automate Impromptu Using Macros 65

Chapter 5: Expression Automation


Token ID Name Optional Parameters

83 84 85 90

descending report rows function

none none none info 1: a case-sensitive string representing the name of the function to add. The function name must exist in either the Impromptu function table or the function table of the catalog where the expression resides.

100 101 102 103 104 105 106 107 110

left parenthesis right parenthesis comma map default prefilter null userID prompt

none none none none none none none none none

66 Automate Impromptu Using Macros

Chapter 6: Report Automation

Automate Impromptu Usng Macros 67

Chapter 6: Report Automation

PublishHTML Object
Description

An object that controls the creation of HyperText Markup Language (HTML) reports.
Discussion

Use the PublishHTML object to publish an Impromptu report as HTML.


Example

The following example opens a report called annsales.imr and publishes it as HTML. The HTML files are placed in the folder called "tmp", and all the files have the prefix "myfiles".
Dim ImpApp as Object Dim htmlObj as Object Dim ImpRep as Object Sub Main() Set ImpApp = CreateObject("Impromptu.Application.40") ImpApp.OpenCatalog "c:\cognos\Great Outdoors Sales Data.cat", _ "Creator" Set ImpRep = ImpApp.OpenReport _ ("c:\cognos\reports\annual product sales.imr") Set htmlObj = ImpRep.PublishHTML htmlObj.Publish "c:\tmp","myfiles" End Sub

68 Automate Impromptu Usng Macros

Chapter 6: Report Automation

Method Name

Description

ClearTOCColumns Publish Reset

Removes all columns from the HTML Report Navigator. Publishes the referenced report as HTML. Resets the PublishHTML object to the settings as they were last saved in the Options box (Publish As HTML dialog box). Adds the specified grouped column to the Report Navigator when a report is published as HTML.
Description

TOCAddColumn

Property Name

ExportMetaTags FromPage

Determines whether HTML meta tags will be added to the HTML report. Sets which page of the Impromptu report will be the first page of the HTML report.

SuppressTOCDuplicates Controls what information is added to the Report Navigator when a report is ExportMetaTagspublished as HTML. TOC TOCByPageNumber Sets whether the HTML report includes the Report Navigator. Sets whether the Report Navigator contains page numbers and activates the Report Navigator. Sets whether the Report Navigator appears in a separate page or in a frame and activates the Report Navigator. Sets which page of the Impromptu report will be the last page of the HTML report.

TOCInFrame

ToPage

Automate Impromptu Usng Macros 69

Chapter 6: Report Automation

Report Document Object


Description

An Impromptu report.
Discussion

Use a Report Document object to open an Impromptu report within an OLE automation script. Note: Always use the OpenReport method in conjunction with an Impromptu Application object to open an Impromptu report in an OLE automation script. The use of GetObject to open existing Impromptu reports is not supported
Example

The following example, opens a report and then saves it as a snapshot. It then mails the report to a subscription list using Microsoft Mail. Note the creation and use of a Pause subroutine that forces the macro to wait when using SendKeys. In some cases (especially when using SendKeys), you may have to implement pauses in the macro to ensure that macro commands remain synchronized with the macro as it executes.
Dim ImpRep as Object Dim Report As String Declare Sub MailReport(ReportName$) Declare Sub Pause(n) Sub Pause(n) For x = 1 to (n * 1000) Next x End Sub Sub MailReport(ReportName As String) AppActivate "Mail" Pause 2 SendKeys "% r" 'Restore Mail window SendKeys "%mn" 'Mail a new Note ... SendKeys "Europe Mgrs" Pause 2 SendKeys "{Tab}{Tab}" ' Tab to Subject line and Pause 2 SendKeys "European Totals Report" ' Enter Subject SendKeys "{Tab}" 'Tab to message area and enter message Pause 2 SendKeys "Attached is summary report for the European Region. " SendKeys "Please review and distribute to your direct reports." Pause 2 SendKeys "{Enter}{Enter}" Pause 2 SendKeys "%a" ' Attach SendKeys ReportName$ 'Enter Name of report to attach Pause 3 SendKeys "%a" 'Press Attach button

70 Automate Impromptu Usng Macros

Chapter 6: Report Automation


Pause 3 SendKeys "%o" 'Press Close button Pause 2 SendKeys "%s" 'Press Send button Pause 2 SendKeys "% n" 'Minimize Mail End Sub Sub Main() Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "c:\imp\samples\outdoors.cat", "Creator" Report$ = InputBox$("Report to Mail?","Mail Impromptu Report") Set ImpRep = ImpApp.OpenReport(Report$) Report$ = ImpRep.FullName ImpRep.RetrieveAll ImpRep.Save 1 ImpRep.CloseReport ImpApp.Quit Set ImpRep = Nothing Set ImpApp = Nothing MailReport Report$ End Sub .

Method Name

Description

Activate ApplyTemplate CloseReport CopyToClipboard

Activates the window associated with the specified report. Uses the specified template to format the active report. Closes the active report without saving it. Copies selected report objects to the Clipboard.

CopySpecialToClipboard Copies report objects to the Clipboard for linking within another application. CreateSnapshot Export ExportASCII ExportdBASE ExportExcel ExportHotFile ExportLotus Creates a snapshot for the active report. Exports the active report in one of a variety of formats. Exports the active report as a delimited ASCII (CSV) file. Exports the active report as a dBASE (DBF) file. Exports the active report as an Excel (XLS) file. Exports the active report as an Impromptu HotFile. Exports the active report as a Lotus (WKn) file.

Automate Impromptu Usng Macros 71

Chapter 6: Report Automation


Method Name Description

ExportData ExportSQL ExportText ExportTransformer GetDataValue

Exports the active report as a PowerPlay (DAT) file. Exports the active report as a Structured Query Language (SQL) file. Exports the active report as a Text (TXT) file. Exports the active report as a PowerPlay Transformer (IQD) file. Returns the data value from a specific occurrence for a specific data item in the active query. Returns selected text. Prints the active report. Displays the Data tabQuery dialog box and suspends your macro to await your input to any tab in the Query dialog box. Retrieves all data from the active reports database. Executes the query for the active report. Retrieves a specific number of rows from the active reports database. Saves the active report with a different name in either report or snapshot format. Saves the active report in either report or snapshot format. Removes internal snapshots and retrieves data from the active reports database.
Description

GetSelectedText Print, PrintOut QueryDialog

RetrieveAll ReExecute RetrieveRows SaveAs Save UseDatabase

Property Name

AllSelectedFrames

Returns a list of the selected frame objects and their child objects on the active Report Document. Returns the Application object thats used to access the report document. Returns which document has returned errors when running multiple documents. Returns the full name of the document, including the path.

Application ErrorDocument FullName

72 Automate Impromptu Usng Macros

Chapter 6: Report Automation


Property Name Description

Modified

Returns a Boolean value based on whether the document has been modified since the last time it was saved. Returns the file name for the active document. Returns the path in which the document is stored. Returns an object that is an HTML representation of a Report Document object. Returns a list of the selected frame objects on the active Report Document. Returns the SQL string from the Profile tab Query dialog box. Returns or sets the document description. Sets or returns whether the application window is visible.

Name Path PublishHTML SelectedFrames SQL Title Visible

SelectedFrame Object
Description

An object that represents a selected frame on a Report Document.


Discussion

Each SelectedFrame object represents an individual frame on a Report Document that has been selected by a user. All such objects are contained in a SelectedFrames collection. The collection of selected frames is returned when either the SelectedFrames or AllSelectedFrames properties are applied to a Report Document object. Individual SelectedFrame objects within the collection can be referenced by adding an index value to the property or by using the Item property with an index value

Automate Impromptu Usng Macros 73

Chapter 6: Report Automation


Example

This macro returns a SelectedFrame object and displays the values for the Name, Formula, DatabaseItem and QueryItem, properties, as applicable.
Sub Main() Dim objImpApp As Object Dim objImpRep As Object Dim objSelectedFrame As Object Set objImpApp = CreateObject("Impromptu.Application") Set objImpRep = objImpApp.ActiveDocument Set objSelectedFrame = objImpRep.SelectedFrames(1) With objSelectedFrame MsgBox .Name MsgBox .Formula MsgBox .DatabaseItem MsgBox .QueryItem End With Set objSelectedFrame = Nothing Set objImpRep = Nothing Set objImpApp = Nothing End Sub

Property Name

Description

QueryItem

Returns a string that contains the query column item for a selected text frame. Returns an empty string for non-text frames. Returns a string that contains the fully qualified database column for a selected text frame. Returns an empty string for non-text frames and for text frames defined by calculations involving more than one database column. Returns a string that contains the fully qualified formula for a selected text frame. Returns an empty string for non-text frames. Returns the name of a SelectedFrame object as a string.

DatabaseItem

Formula

Name

74 Automate Impromptu Usng Macros

Chapter 6: Report Automation

SelectedFrames Collection
Description

A collection of frame objects selected by a user on a Report Document.


Discussion

A collection of selected frame objects is returned by either the SelectedFrames or AllSelectedFrames properties. The objects are arranged in the collection in the order in which they were selected. Individual SelectedFrame objects within the collection can be referenced by adding an index value to the property or by using the Item property with an index value. Use the Count property to determine the number of objects in the collection

Property Name

Description

Count Item
Example

Returns the number of items in the collection. Returns the specified item in the collection.

This macro returns the number of SelectedFrames in each of two SelectedFrames collections created, objList and objFullList.
Sub Main() Dim objImpApp As Object Dim objImpRep As Object Dim objList As Object Dim objFullList As Object Dim intParentFrames As Integer Dim intChildFrames As Integer Set objImpApp = CreateObject("Impromptu.Application") Set objImpRep = objImpApp.ActiveDocument Set objList = objImpRep.SelectedFrames Set objFullList = objImpRep.AllSelectedFrames intParentFrames = objList.Count intChildFrames = objFullList.Count - objList.Count MsgBox "Parent Frames: " & intParentFrames MsgBox "Child Frames: " & intChildFrames Set objFullList = Nothing Set objList = Nothing Set objImpRep = Nothing Set objImpApp = Nothing End Sub

Automate Impromptu Usng Macros 75

Chapter 7: Stored Procedures Automation

Automate Impromptu Using Macros 77

Chapter 7: Stored Procedures Automation

Stored Procedure Object


Description

A Database stored procedure.


Discussion

Use Stored Procedure objects to access and execute database stored procedures
Example

The following example runs a stored procedure on an SQL Server database. The procedure simply determines the total number of Impromptu users that are currently attached to the database and displays this number in Impromptu. The stored procedure thats run from the macro looks like this:
create procedure sp_impusers @appname varchar(30), @server varchar(30) out @cnt int out as select @cnt=count(program_name) from master.dbo.sysprocesses where program_name = @appname select @server = @@SERVERNAME select @cnt, @server

78 Automate Impromptu Using Macros

Chapter 7: Stored Procedures Automation The CognosScript macro looks like this:
Sub Main() Dim ImpApp As Object Dim ImpSP As Object Dim sAppName As String Dim sServerName As String Dim iCnt As Integer Dim smsg As String On Error Goto SPErr sAppName = "Impromptu" Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "c:\imp\workspce\sqlsrvr.cat" Set ImpSP = ImpApp.CreateStoredProcedure ImpSP.SetProcedure _ "sp_impusers(Char[255] IN, Char[255] OUT, OUT)" ImpSP.Execute sAppName, sServerName, iCnt sMsg = sAppName + " processes running..." sMsg = sMsg + cStr(ImpSP.GetParameter(3)) MsgBox sMsg, 64,"Server: ",RTrim$(ImpSP.GetParameter(2)) Exit Sub SPErr: MsgBox CStr(Err) & " " & Error$ Resume SPEnd SPEnd: End Sub

Method Name

Description

Execute GetParameter SetProcedure

Executes the stored procedure. Returns the value of an output parameter from the stored procedure. Sets the name of the stored procedure.

Automate Impromptu Using Macros 79

Chapter 8: Methods

Automate Impromptu Using Macros 81

Chapter 8: Methods

Activate Method
Syntax

object.Activate
Applies To

Application
Description

Report Document Steps This method Brings the visible Impromptu application to the front of the desktop as the active application. Activates the window associated with the specified Report Document.
Discussion

Use this method to bring the visible Impromptu application or report document to the forefront. When you create an automation procedure that involves several different reports, you need some way to set the focus on the different reports involved.
Return Type

Nothing
Example

For example, to bring the visible Impromptu application (named ImpApp) to the forefront of your desktop, insert the following into the macro:
ImpApp.Activate

For example, if you have an automation procedure that starts Impromptu and opens four different reports. The automation procedure is currently focused on one report (named ImpRep2). To shift the focus to another report (named ImpRep4), you can use the following in the macro:
ImpRep4.Activate

82 Automate Impromptu Using Macros

Chapter 8: Methods

Add Method (CatalogLevels, SchemaLevels, Tables, UserClasses)


Syntax

object.Add Name
Applies To

CatalogLevels SchemaLevels Tables UserClasses


Description

Adds a new object into the collection.

Discussion

For CatalogLevels, SchemaLevels, Tables, and UserClasses collection, the add method will fail if no corresponding object exists for the name, or if a name of the wrong type is supplied.
Parameters Description

Name

Required. Specifies the name for the new object. Type: String

Return Type

Object (CatalogLevels, SchemaLevels, Tables)

Automate Impromptu Using Macros 83

Chapter 8: Methods
Example

The following example creates a new catalog, sets the Database object, inserts two qualification levels, adds a second CatalogLevel object, adds two SchemaLevel objects to the second CatalogLevel object, and adds a second SchemaLevel object to the first CatalogLevel object. The resources allocated to the objects are then released.
Option Explicit Sub Main() Dim DB As Object Dim ImpApp As Object Dim ImpCat As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.CreateCatalog "C:\Catalogs\Sample.cat", "OUTDOORS", 0 Set ImpCat = ImpApp.ActiveCatalog Set DB = ImpCat.Databases("OUTDOORS") DB.InsertQualificationLevel "Schema 1a", 1 DB.InsertQualificationLevel "Catalog 1", 0 DB.CatalogLevels.Add "Catalog 2" DB.CatalogLevels(2).SchemaLevels.Add "Schema 2a" DB.CatalogLevels(2).SchemaLevels.Add "Schema 2b" DB.CatalogLevels(1).SchemaLevels.Add "Schema 1b" Set DB = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

Add Method (Columns)


Syntax

Columns.Add ColumnName, ColumnType


Applies To

Columns
Description

Adds a new object into the collection.

Discussion

For Columns collections, the add method will fail if a non-existent name or an out-of-range value of the Type parameter is supplied.

84 Automate Impromptu Using Macros

Chapter 8: Methods
Parameters Description

ColumnName

Required. Specifies the name of the new Column object. Type: String Required. Specifies the Impromptu data type of the new column object. Type: Integer Use the following values to specify the data type: 1 = Character 2 = Variant Character 3 = Long Variant Character 4 = Small Int 5 = Integer 6 = Decimal 7 = Float 8 = Double 9 = Binary 10 = Var Binary 11 = Quad 12 = Date 13 = Time 14 = DateTime 15 = Interval 16 = Database Key 17 = Blob 18 = Text 19 = Blob Array

ColumnType

Automate Impromptu Using Macros 85

Chapter 8: Methods
Return Type

Object
Example

The following example creates a new catalog, sets the Database object, inserts two qualification levels, adds a second CatalogLevel object, adds two SchemaLevel objects to the second CatalogLevel object, and adds a second SchemaLevel object to the first CatalogLevel object. The resources allocated to the objects are then released.
Option Explicit Sub Main() Dim DB As Object Dim ImpApp As Object Dim ImpCat As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.CreateCatalog "C:\Catalogs\Sample.cat", "OUTDOORS", 0 Set ImpCat = ImpApp.ActiveCatalog Set DB = ImpCat.Databases("OUTDOORS") DB.InsertQualificationLevel "Schema 1a", 1 DB.InsertQualificationLevel "Catalog 1", 0 DB.CatalogLevels.Add "Catalog 2" DB.CatalogLevels(2).SchemaLevels.Add "Schema 2a" DB.CatalogLevels(2).SchemaLevels.Add "Schema 2b" DB.CatalogLevels(1).SchemaLevels.Add "Schema 1b" Set DB = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

86 Automate Impromptu Using Macros

Chapter 8: Methods

Add Method (DatabaseDefinitions, Databases)


Syntax

Databases.Add LogicalDatabaseName
Applies To

DatabaseDefinitions Databases
Description

Adds a new object into the collection.

Discussion

For Databases collections, the add method will fail when there is no DatabaseDefinition object with the name in the LogicalDatabaseName property.
Parameters Description

LogicalDatabaseName

Required. Specifies the logical database name corresponding to the Name property of a DatabaseDefinition object. Type: String

Automate Impromptu Using Macros 87

Chapter 8: Methods
Return Type

Object
Example

The following example creates a new catalog, sets the Database object, inserts two qualification levels, adds a second CatalogLevel object, adds two SchemaLevel objects to the second CatalogLevel object, and adds a second SchemaLevel object to the first CatalogLevel object. The resources allocated to the objects are then released.
Option Explicit Sub Main() Dim DB As Object Dim ImpApp As Object Dim ImpCat As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.CreateCatalog "C:\Catalogs\Sample.cat", "OUTDOORS", 0 Set ImpCat = ImpApp.ActiveCatalog Set DB = ImpCat.Databases("OUTDOORS") DB.InsertQualificationLevel "Schema 1a", 1 DB.InsertQualificationLevel "Catalog 1", 0 DB.CatalogLevels.Add "Catalog 2" DB.CatalogLevels(2).SchemaLevels.Add "Schema 2a" DB.CatalogLevels(2).SchemaLevels.Add "Schema 2b" DB.CatalogLevels(1).SchemaLevels.Add "Schema 1b" Set DB = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

88 Automate Impromptu Using Macros

Chapter 8: Methods

Add Method (TableLinks)


Syntax

TableLinks.Add LeftTable, RightTable


Applies To

TableLinks
Description

Adds a new object into the collection.

Discussion

For TableLinks collection, the add method will fail if no corresponding object exists for the name, or if a name of the wrong type is supplied.
Parameters Description

LeftTable RightTable

Required. Specifies the "left" table object. Type: Object Required. Specifies the "right" table object. Type: Object

Automate Impromptu Using Macros 89

Chapter 8: Methods
Return Type

Object
Example

The following example creates a new catalog, sets the Database object, inserts two qualification levels, adds a second CatalogLevel object, adds two SchemaLevel objects to the second CatalogLevel object, and adds a second SchemaLevel object to the first CatalogLevel object. The resources allocated to the objects are then released.
Option Explicit Sub Main() Dim DB As Object Dim ImpApp As Object Dim ImpCat As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.CreateCatalog "C:\Catalogs\Sample.cat", "OUTDOORS", 0 Set ImpCat = ImpApp.ActiveCatalog Set DB = ImpCat.Databases("OUTDOORS") DB.InsertQualificationLevel "Schema 1a", 1 DB.InsertQualificationLevel "Catalog 1", 0 DB.CatalogLevels.Add "Catalog 2" DB.CatalogLevels(2).SchemaLevels.Add "Schema 2a" DB.CatalogLevels(2).SchemaLevels.Add "Schema 2b" DB.CatalogLevels(1).SchemaLevels.Add "Schema 1b" Set DB = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

90 Automate Impromptu Using Macros

Chapter 8: Methods

Add Method (DeniedCatalogs, DeniedColumns, DeniedFolderItems, DeniedSchemas, DeniedSelectedValues, DeniedTables)


Syntax

Object.Add(Item)
Applies To

DeniedCatalogs DeniedColumns DeniedFolderItems DeniedSchemas DeniedSelectValues DeniedTables


Description

Adds an existing item to the collection.


Descriptio

Parameters

Item

Required. Specifies the object to be added to the collection. Type: Object For DeniedCatalogs, this parameter is a CatalogLevel object. For DeniedSchemas, this parameter is a SchemaLevel object. For DeniedSelectValues, this parameter is a FolderItem object.

Automate Impromptu Using Macros 91

Chapter 8: Methods
Return Type

Empty
Example

The following example creates a new catalog, sets the Database object, inserts two qualification levels, adds a second CatalogLevel object, adds two SchemaLevel objects to the second CatalogLevel object, and adds a second SchemaLevel object to the first CatalogLevel object. The resources allocated to the objects are then released.
Option Explicit Sub Main() Dim DB As Object Dim ImpApp As Object Dim ImpCat As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.CreateCatalog "C:\Catalogs\Sample.cat", "OUTDOORS", 0 Set ImpCat = ImpApp.ActiveCatalog Set DB = ImpCat.Databases("OUTDOORS") DB.InsertQualificationLevel "Schema 1a", 1 DB.InsertQualificationLevel "Catalog 1", 0 DB.CatalogLevels.Add "Catalog 2" DB.CatalogLevels(2).SchemaLevels.Add "Schema 2a" DB.CatalogLevels(2).SchemaLevels.Add "Schema 2b" DB.CatalogLevels(1).SchemaLevels.Add "Schema 1b" Set DB = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

92 Automate Impromptu Using Macros

Chapter 8: Methods

AddFolder Method
Syntax

Items.AddFolder(Name, [Table])
Applies To

Folders Items
Description

Adds a folder (sub-folder) to another folder.


Discussion

The name of the folder to be added must be valid. Its name must be unique within the parent folder.
Parameters Description

Name Table

Required. The name of the folder to be added. Optional. Specifying a table as the second parameter will automatically add all columns from that database table

Return Type

Object
Example

This macro adds the folder Admin to the active catalog. First, three objects are declared. The application object is created and assigned to the ImpApp variable. An already open catalog is made active. The folders for the new catalog are assigned to the CatFolders variable. A new folder (Admin) is added. The catalog is saved and the resources for the object variables are released. Note: A catalog must already be open. This macro does not work if the "Admin." folder already exists.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim CatFolders As Object Set ImpApp = CreateObject("Impromptu.Application") Set ImpCat = ImpApp.ActiveCatalog Set CatFolders = ImpCat.Folders CatFolders.AddFolder "Admin." ImpCat.Save Set CatFolders = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

Automate Impromptu Using Macros 93

Chapter 8: Methods

AddItem Method (Use parameter)


Syntax

Items.AddItem(Name, [Use])
Applies To

Folders Items
Description

Adds an expression to a folder.


Discussion

AddItem requires that the destination folder be valid and that the item name in the destination folder be unique. If the Use parameter is included, the expression type for the value must match the intended use or an error is returned. If the Use parameter is not included, AddItem proceeds as if the Use parameter had a value of 0 (automatic). When the Use parameter has a value of 0, a Boolean expression is interpreted as a condition (2), and all other expressions are interpreted as a calculation (1). When the Use parameter has a value of 1, the expression is evaluated as a calculation. When the Use parameter has a value of 2, the expression is evaluated as a Boolean expression. When the Use parameter has a value of 3, the expression is evaluated as a catalog folder prompt. The actual prompt expression is defined using the Append method. When run, the created expression is validated to ensure it contains a single prompt token. Together, AddItem and Append allow simple prompts to be created without the need to code a dialog box.
Parameters Description

Name Use

Required. Gives the name of the expression object to be added. (Type String) Optional. A value (Integer) that specifies the type of expression being added. Possible values are 0 - automatic (default) 1 - calculation 2 - condition 3 - prompt

94 Automate Impromptu Using Macros

Chapter 8: Methods
Return Type

Object
Example

This macro prompts a user to enter a maximum price to be used in getting data. Prompting involves use of both the AddItem and Append methods. Here, the Append method provides the prompt message and a default value.
Sub Main() Dim objImpApp As Object Dim objImpCat As Object Dim objCatFolders As Object Dim objPrompt As Object Dim objPromptFolder As Object Const strCatalogPath = "C:\Cognos\Catalogs\" Const use_prompt = 3 Const token_prompt = 110 Const token_typein = 1 Set objImpApp = CreateObject("Impromptu.Application") objImpApp.OpenCatalog strCatalogPath & _ "great outdoors with prompts.cat", "Creator" Set objImpCat = objImpApp.ActiveCatalog Set objCatFolders = objImpCat.Folders 'add prompt folder Set objPromptFolder = objCatFolders.AddFolder("Catalog Prompts") Set objPrompt = objPromptFolder.Items.AddItem("Prompt for" & _ " the price limit", use_prompt) objPrompt.Value.Append token_prompt, token_typein, _ "What is the maximum price?", 2, 1999.99 objPrompt.Value.Commit objImpCat.Save objImpCat.Close Set objPrompt = Nothing Set objPromptFolder = Nothing Set objPrompt = Nothing Set objCatFolders = Nothing Set objImpCat = Nothing Set objImpApp = Nothing End Sub

Automate Impromptu Using Macros 95

Chapter 8: Methods The next macro adds an item to a folder, and an expression to the item. Seven objects are declared. The application object is assigned to the ImpApp variable. A catalog is opened and made active. The first database is referenced and assigned to the DB variable. The folders are assigned to the CatFolders variable. A new folder, Customers, is added. A new column, Order No., is added to the Customers folder. An expression is created for the new item to append the values from the ORDER_NO column to the new column. The expression is saved, all changes are saved, and the resources assigned to the object variables are released.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim CatFolders As Object Dim NewFolder As Object Dim NewColumn As Object Dim NewColumnExpression As Object Dim DB As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\temp\great sample.cat", "Creator" Set ImpCat = ImpApp.ActiveCatalog Set DB = ImpCat.Databases(1) Set CatFolders = ImpCat.Folders Set NewFolder = CatFolders("Customers") Set NewColumn = NewFolder.Items.AddItem("Order No.") Set NewColumnExpression = NewColumn.Value NewColumnExpression.Append DB.Tables("ORDER").Columns("ORDER_NO") NewColumnExpression.Commit ImpCat.Save Set CatFolders = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

96 Automate Impromptu Using Macros

Chapter 8: Methods

AddItem Method (Column parameter)


Syntax

Items.Additem([Name], Column)
Applies To

Folders Items
Description

Adds an expression to a folder.


Discussion

For this operation to succeed, the destination folder must be valid, and the item name must be unique in the destination folder.
Parameters Description

Name

Optional. If not provided, specifies the name of the column passed as the second argument will be used for the name of the new folder item. Type: String Required. Specifies the database column on which the new folder item is based. Type: String

Column

Return Type

Object

Automate Impromptu Using Macros 97

Chapter 8: Methods
Example

This macro adds an item to a folder, and an expression to the item. Seven objects are declared. The application object is assigned to the ImpApp variable. A catalog is opened and made active. The first database is referenced and assigned to the DB variable. The folders are assigned to the CatFolders variable. A new folder, Customers, is added. A new column, Order No., is added to the Customers folder. An expression is created for the new item to append the values from the ORDER_NO column to the new column. The expression is saved, all changes are saved, and the resources assigned to the object variables are released.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim CatFolders As Object Dim NewFolder As Object Dim NewColumn As Object Dim NewColumnExpression As Object Dim DB As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\temp\great sample.cat", "Creator" Set ImpCat = ImpApp.ActiveCatalog Set DB = ImpCat.Databases(1) Set CatFolders = ImpCat.Folders Set NewFolder = CatFolders("Customers") Set NewColumn = NewFolder.Items.AddItem("Order No.") Set NewColumnExpression = NewColumn.Value NewColumnExpression.Append _ DB.Tables("ORDER").Columns("ORDER_NO") NewColumnExpression.Commit ImpCat.Save Set CatFolders = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

98 Automate Impromptu Using Macros

Chapter 8: Methods

AddTable Method
Syntax

Application.AddTable [Database] ,[HostCatalog] ,[Schema] ,Table


Applies To

Application
Description

Adds a table to the catalog.


Discussion

Use the AddTable method to add new tables to an open catalog. When a database is restructured or updated, or when the name of an existing table is changed, use the AddTable method to keep the catalogs up-todate. The AddTable method returns a Boolean value (-1=TRUE, 0=FALSE) based on whether the table was added successfully. Do not specify a HostCatalog and a Schema unless the database tables you're accessing can be qualified, as in the following table:
Database HostCatalog is ... Schema is ...

Oracle Sybase MS SQLServer Informix Ingres Interbase ODBC SQLBase dBASE IV Paradox 4.0 Btrieve 6.1, 5.x

not applicable database database not applicable not applicable not applicable table qualifier database not applicable not applicable not applicable

database owner database owner database owner database owner database owner not applicable table owner creator not applicable not applicable not applicable

Automate Impromptu Using Macros 99

Chapter 8: Methods
Parameters Description

Database

Optional. Specifies the Impromptu logical name of the database or HotFile to which the table is added. If the current catalog contains only a single, simple database, with no Host Catalog or Schema, then Database is not required. For catalogs that contain multiple HotFiles and a database at the highest level, Database is required.

HostCatalog

Optional. Required only for databases that have a Host Catalog. For Sybase databases, the HostCatalog is the database. This parameter is case sensitive.

Schema

Optional. Required only for databases that have a schema. For both Oracle and Sybase, the Schema is the owner. This parameter is case sensitive.

Table

Required. Specifies the name of the table to be added to the catalog. Table must be the name of one of the tables in the database that's used by the catalog. This parameter is case sensitive.

Example

This example adds "Product" table to the catalog. If the table already exists it will cause an error.
Sub Main() Dim objImpApp As Object Set objImpApp = CreateObject("Impromptu.Application") objImpApp.Visible 1 objImpApp.OpenCatalog "C:\impromptu50\Samples\Reports\" & _ "Great Outdoors Sales Data.CAT", "Creator" objImpApp.AddTable "Outdoors",,,"product" Set objImpApp = Nothing End Sub

100 Automate Impromptu Using Macros

Chapter 8: Methods

Append Method
Syntax

Expression.Append(Token, [Info1])
Applies To

Expression
Description

Appends a single token or an entire expression.


Discussion

Pass any one of the following: the ID of the token you wish to add (see the Token Table) the expression you would like to add to the end of this expression the string you want to append to the expression Tokens are entered using the Append method with the actual numerical value. If you are using Visual Basic, you can create a label to describe each of the token types using the "Const" directive.
Parameters Description

Token

Required. This value may be an integer or an object. If an integer, it is the number that represents the token to be added (see the Token Table). If an object, it must be either: an Expression object whose tokens are copied into this expression. a catalog column object, or [Info1].

Info1

Optional. This value may be a string, integer, or a date/time constant. It is required by some tokens. See the Token Table. If a string, this value represents an alternate name for the Catalog data object (if the first argument is a catalog column object). If the first argument is an integer (a token), this value will represent any additional information required by the token. See the Token Table.

Return Type

Nothing Automate Impromptu Using Macros 101

Chapter 8: Methods
Example

This macro adds calculation and condition columns to a catalog. The application object is created and assigned to the ImpApp object. An existing catalog is opened, made the active catalog, and assigned to the ImpCat variable. The folders for the catalog are assigned to the CatFolders variable. The Sale Amount calculation is added to OrdrDetl in the Order folder. The expression is created using a series of Append statements. The Closed Sale folder is added to the Conditions item in the Orders folder. The expression is created using a series of Append statements. Finally, the changes are committed and the catalog is saved.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim CatFolders as Object Dim NewColumnExpression As Object Dim NewColumn As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\Catalogs\GO Sample.cat", "Creator" Set ImpCat = ImpApp.ActiveCatalog set CatFolders = ImpCat.Folders 'add calculation column to Order folder Set NewColumn = CatFolders("Order").Items("Ordrdetl") _ .Items.AddItem ("Sale Amount", 1) Set NewColumnExpression = NewColumn.Value With NewColumnExpression .Append 100 '( .Append 2, 1 'numeric constant 1 .Append 23 '.Append _ CatFolders("Order").Items("Ordrdetl").Items("Disc Prcnt").Value .Append 21 '/ .Append 2, 100 'numeric constant 100 .Append 101 ') .Append 20 '* .Append 100 '( .Append _ CatFolders("Order").Items("Ordrdetl").Items("Price").Value .Append 20 '* .Append _ CatFolders("Order").Items("Ordrdetl").Items("Qty").Value .Append 101 ') .Commit End With 'Add closed sale filter column to the subfolder Conditions Set NewColumn = _ CatFolders("Order").Items("Conditions").Items.AddItem _ ("Closed Sale", 2) Set NewColumnExpression = NewColumn.Value NewColumnExpression.Append _ CatFolders("Order").Items("Closed Dt").Value NewColumnExpression.Append 36 'is not missing NewColumnExpression.Commit ImpCat.Save End Sub

102 Automate Impromptu Using Macros

Chapter 8: Methods

ApplyTemplate Method
Syntax

ReportDocument.ApplyTemplate template
Applies To

Report Document
Description

Applies a template to the specified report document for report formatting.


Discussion

Templates can control the look and content of a report by applying calculations and conditionals to the data items in the report. Use ApplyTemplate to apply standard filters to a report or to provide a standard look to sets of reports.
Parameters Description

template

Required. Specifies the name of the template to be applied to the specified Report Document object.

Example

In the following example, the ApplyTemplate method applies either an invoice or a check template based on the values returned in the report. The report returns a single valuethe current balance owing for a customer. Depending on whether the balance is negative or positive, either a check or an invoice is printed.
Dim ImpApp As Object Dim ImpRep As Object Dim TotalSales As Integer Set ImpApp = CreateObject("Impromptu.Application") Set ImpRep = ImpApp.OpenReport "c:\imp\workspce\custbal.imr" ImpRep.RetrieveAll TotalSales = ImpRep.GetDataValue(1,1) If TotalSales < 0 Then 'negative value = customer credit ImpRep.ApplyTemplate "c:\imp\workspce\check.imt" ElseIf TotalSales > 0 Then 'positive value = balance owing ImpRep.ApplyTemplate "c:\imp\workspce\invoice.imt" End If ImpRep.Print

Automate Impromptu Using Macros 103

Chapter 8: Methods

CatalogName Method
Syntax

Application.CatalogName
Applies To

Application
Description

Returns a string containing the name of the currently open catalog. If no catalog is currently open, CatalogName returns NULL.
Return Type

String
Example

This example displays the name of the active catalog.


Sub Main() Dim objImpApp As Object Dim strCatName As String Set objImpApp = CreateObject("Impromptu.Application") strCatName = objImpApp.CatalogName If strCatName <> "" Then Msgbox "The currently open catalog is:" & strCatName Else Msgbox "No catalog is currently open." End If Set objImpApp = Nothing End Sub

104 Automate Impromptu Using Macros

Chapter 8: Methods

CatalogOpened Method
Syntax

Application.CatalogOpened
Applies To

Application
Description

Returns a Boolean value (-1=TRUE, 0=FALSE) depending on whether the catalog is open.
Return Type

Boolean
Example

This example returns a message indicating whether or not a catalog is open.


Sub Main() Dim objImpApp As Object Set objImpApp = CreateObject("Impromptu.Application") Const Cat_Open = -1 If objImpApp.CatalogOpened = Cat_Open Then Msgbox "There is an open catalog." Else Msgbox "No catalog is currently open." End If Set objImpApp = Nothing End Sub

Automate Impromptu Using Macros 105

Chapter 8: Methods

ChangeUserClass Method
Syntax

Application.ChangeUserClass ClassName, [ClassPassword], [DataBaseUserID], [DataBasePassword], [ConnectToDatabase]


Applies To

Application
Description

Changes the current user class.


Discussion

Use the ChangeUserClass method to change the current user class for the catalog. Changing the user class changes the catalog settings for things such as the accessible tables and folders, and the report governor settings. The ChangeUserClass method returns a Boolean value based on whether the user class was successfully changed. A value of 0 (FALSE) indicates that the change did not occur successfully. A value of -1 (TRUE) indicates that the change did occur successfully. When the Cognos Scheduler executes a macro that runs an Impromptu report, the Scheduler passes Impromptu all security information required by both Impromptu and the database.
Parameters Description

ClassName ClassPassword DataBaseUserID DataBasePassword ConnectToDatabase

Required. Specifies the name of the user class to change. Optional. Specifies a password for the user class. Optional. Replies to a database prompt for a user ID for the user class Optional.Replies to a database prompt for a user password for the user class Optional. Overrides the current Impromptu setting for connecting to the database.

106 Automate Impromptu Using Macros

Chapter 8: Methods
Example

This example changes the active user class for the active catalog to another existing user class. A catalog must be active.
Sub Main() Dim objImpApp As Object Set objImpApp = CreateObject("Impromptu.Application") objImpApp.ChangeUserClass "User" Set objImpApp = Nothing End Sub

Clear Method
Syntax

Expression.Clear
Applies To

Expression
Description

Empties the expression.


Discussion

This method clears the current expression so a new one can be built.
Return Type

Nothing

Automate Impromptu Using Macros 107

Chapter 8: Methods
Example

This macro edits the Product Margin calculation column in the sample catalog. Four object variables are declared. The application object is created and assigned to the ImpApp variable. A catalog is opened, made active, and assigned to the ImpCat variable. The folders are assigned to the CatFolders object. The column "Product Margin" is assigned to the CatColumn variable. The expression is cleared and a new one added. Before ending, the macro releases all resources allocated to the object variables. Note: You should use a valid folder and column name, as well as catalog path.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim CatFolders as Object Dim CatColumn As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C: \temp\sample.cat", "Creator" Set ImpCat = ImpApp.ActiveCatalog Set CatFolders = ImpCat.Folders 'edit the calculation column in the Products folder Set CatColumn = CatFolders("Products").Items("Product Margin") CatColumn.Clear 'clears the existing expression CatColumn.Append _ CatFolders("Products").Items("Product Price").Value CatColumn.Append 23 'CatColumn.Append _ CatFolders("Products").Items("Product Cost").Value CatColumn.Commit Set CatColumn = Nothing Set CatFolders = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

ClearTOCColumns Method
Syntax

PublishHTML.ClearTOCColumns
Applies To

PublishHTML
Description

Removes all columns from the HTML Report Navigator.


Return Type

Nothing

108 Automate Impromptu Using Macros

Chapter 8: Methods

Close Method
Syntax

Catalog.Close
Applies To

Catalog
Description

Closes the active catalog.


Discussion

Use this method to close the active catalog. This method automatically saves all changes to the catalog and closes any open reports belonging to the catalog.
Return Type

Nothing
Example

This macro opens a catalog, makes it active, then closes it.


Sub Main() Dim ImpApp As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "GO Sample.cat", "OUTDOORS" ImpApp.ActiveCatalog.Close ImpApp.Quit Set ImpApp=Nothing End Sub

Automate Impromptu Using Macros 109

Chapter 8: Methods

CloseCatalog Method
Syntax

Application.CloseCatalog
Applies To

Application
Description

Closes the open catalog and the associated reports.


Discussion

Use the CloseCatalog method to close the current catalog and associated reports before opening either a new catalog or a report that's based on another catalog. When this method is executed, all changes to the catalog are saved. The return value is True if the catalog is closed successfully.
Return Type

Boolean
Example

The following macro moves folders and columns, adds new folders, renames folders and columns. The first three lines use the Dim statement to declare three object variables. The next three lines assign values to these object variables. In line 7, a new folder is added. The catalog is then saved and closed. The rest of the macro frees up the resources allocated for the OLE objects.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim CatFolders As Object Set ImpApp = CreateObject("Impromptu.Application") Set ImpCat = ImpApp.ActiveCatalog Set CatFolders = ImpCat.Folders CatFolders.AddFolder "Admin." ImpCat.Save ImpApp.CloseCatalog Set ImpCat = Nothing Set ImpApp = Nothing End Sub

110 Automate Impromptu Using Macros

Chapter 8: Methods

CloseReport Method
Syntax

ReportDocument.CloseReport
Applies To

Report Document
Description

Closes the specified Report Document object.


Discussion

Use the CloseReport method to close the active report. Unlike its interactive equivalent (choosing Close from the File menu), the CloseReport method does not prompt for a save if there are outstanding changes. Use the Modified property to determine whether the report should be saved before closing it. If the report has outstanding changes, use the Save method to save the it.
Return Type

Nothing
Example

This example checks to see if the current report was modified. If the report was modified, it will be saved and then closed. If it wasn't modified, it will be closed.
Sub Main() Dim objImpApp As Object Dim objImpRep As Object Set objImpApp = CreateObject("Impromptu.Application") Set objImpRep = objImpApp.ActiveDocument If objImpRep.Modified = 0 then objImpRep.CloseReport Else objImpRep.Save objImpRep.CloseReport End If Set objImpRep = Nothing Set objImpApp = Nothing End Sub

Automate Impromptu Using Macros 111

Chapter 8: Methods

Commit Method
Syntax

Expression.Commit
Applies To

Expression
Description

Signals that the user has completed all changes using the Append and Clear methods.
Discussion

If the syntax is invalid, an error is caused and changes made after the last Commit are discarded. The maximum size of the expression is 32K.
Return Type

Nothing

112 Automate Impromptu Using Macros

Chapter 8: Methods
Example

This macro adds calculation and condition columns to a catalog. Five object variables are declared. The application object is created and assigned to the ImpApp object. An existing catalog is opened, made the active catalog, and assigned to the ImpCat variable. The folders for the catalog are assigned to the CatFolders variable. The Sale Amount calculation is added to OrdrDetl in the Order folder. The expression is created using a series of Append statements. The Closed Sale folder is added to the Conditions item in the Orders folder. The expression is created using a series of Append statements. Finally, the changes are committed and the catalog is saved.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim CatFolders as Object Dim NewColumnExpression As Object Dim NewColumn As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C: \Catalogs\GO Sample.cat", "Creator" Set ImpCat = ImpApp.ActiveCatalog set CatFolders = ImpCat.Folders 'add calculation column to Order folder Set NewColumn = _ CatFolders("Order").Items("Ordrdetl").Items.AddItem _ ("Sale Amount", 1) Set NewColumnExpression = NewColumn.Value With NewColumnExpression .Append 100 '( .Append 2, 1 'numeric constant 1 .Append 23 '.Append _ CatFolders("Order").Items("Ordrdetl").Items("Disc Prcnt").Value .Append 21 '/ .Append 2, 100 'numeric constant 100 .Append 101 ') .Append 20 '* .Append 100 '( .Append _ CatFolders("Order").Items("Ordrdetl").Items("Price").Value .Append 20 '* .Append _ CatFolders("Order").Items("Ordrdetl").Items("Qty").Value .Append 101 ') .Commit End With 'Add closed sale filter column to the subfolder Conditions Set NewColumn = _ CatFolders("Order").Items("Conditions").Items.AddItem _ ("Closed Sale", 2) Set NewColumnExpression = NewColumn.Value NewColumnExpression.Append _ CatFolders("Order").Items("Closed Dt").Value NewColumnExpression.Append 36 'is not missing NewColumnExpression.Commit ImpCat.Save End Sub

Automate Impromptu Using Macros 113

Chapter 8: Methods

ConnectDatabase Method
Syntax

Application.ConnectDatabase [DataBaseUserID ,DataBasePassword]


Applies To

Application
Description

Connects to the database for the specified catalog and returns a Boolean value based on whether the database was connected successfully. A return value of 0 (FALSE) indicates that the database did not connect successfully. A value of -1 (TRUE) indicates that the connection was successful.
Discussion

Use the ConnectDatabase method to connect to the database for a catalog. Not all of the databases that Impromptu supports require passwords. You can specify database user IDs and passwords for the following: Informix InterBase MDI Database Gateway NET-Gateway ODBC (some odbc drivers) OmniSQL Server Oracle SQLBase Sybase SQL Server Sybase Sybase System 10 For a complete list of supported databses, see Databases Supported in Impromptu.

114 Automate Impromptu Using Macros

Chapter 8: Methods When the Cognos Scheduler executes a macro that runs an Impromptu report, the Scheduler passes Impromptu all security information required by both Impromptu and the database.
Parameters Description

DataBaseUserID

Optional. Replies to the database prompt for a user ID that the automation script uses when connecting to the database. Optional. Replies to the database prompt for a password that the automation script uses when connecting to the database.

DataBasePassword

Automate Impromptu Using Macros 115

Chapter 8: Methods

CopySpecialToClipboard Method
Syntax

ReportDocument.CopySpecialToClipboard [CopyImage] [,StartRow] [,EndRow]


Applies To

Report Document
Description

Copies selected report objects from the specified Report Document object to the Clipboard for use in object linking.
Discussion

Use the CopySpecialToClipboard method to copy either a report image or the current query data to the Clipboard when you want to link the copied object into another application. With no parameters specified, the CopySpecialToClipboard method copies the current report image to the Clipboard. Use the OLE automation methods of target application to paste the report image into the target application. The CopySpecialToClipboard method always returns a Boolean value of 0 (FALSE) regardless of whether the selected objects were successfully copied to the Clipboard. The standard method of copying the report image is like this:
objImpRep.CopySpecialToClipboard

To copy the first three row of report data, it would look like this:
objImpRep.CopySpecialToClipboard 0,1,3

If you want to capture the retorn value, use something like this:
Ret# = objImpRep.CopySpecialToClipboard(0)

Once the image is successfully copied to the Clipboard, use automation methods for other active objects in other applications to paste link the report image. For example, to paste the report into a Microsoft Word document, create a Word Basic OLE object and then use Word's EditPasteSpecial statement to paste link the report image into a document or a line of code like this:
SendKeys "^V" '<CTRL> + V

Note: Before using the CopySpecialToClipboard method, save the current report to disk. If you attempt to perform a paste special in another application before the report is saved, OLE will fail to resolve the link because no physical file exists.

116 Automate Impromptu Using Macros

Chapter 8: Methods
Parameters Description

CopyImage

Optional. Specifies a Boolean value that indicates whether to copy the report image rather then the report data. The default is 1 (copy the report image). Optional. When CopyImage is set to 0, specifies the starting row in a range of rows from the query. The default is the first row in the query. Optional. When CopyImage is set to 0, specifies the last row in a range of rows from the query. The default is the last row in the query.

StartRow

EndRow

Example

This example copies 3 rows of data from the active report to the clipboard.
Sub Main() Dim objImpApp As Object Dim objImpRep As Object Set objImpApp = CreateObject("Impromptu.Application") Set objImpRep = objImpApp.ActiveDocument objImpRep.CopySpecialToClipboard 0, 2, 4 Set objImpRep = Nothing Set objImpApp = Nothing End Sub

Automate Impromptu Using Macros 117

Chapter 8: Methods

CopyTo Method
Syntax

FolderItem.CopyTo(DestinationFolder)
Applies To

FolderItem
Description

Copies the folder items to the destination folder.


Discussion

The destination folder must exist for the command to succeed.


Parameters Description

DestinationFolder

Required. Specifies the destination to which the specified FolderItem object will be copied. Type: Object

Return Type

Object
Example

The following macro copies some folders in a catalog. First, three objects and one integer are declared. The application object is created and assigned to the ImpApp variable. A catalog is created and made active. The folders for the new catalog are assigned to the CatFolders variable. The catalog is given a description, a new folder (Admin) is added, and all the folders are copied to the Admin folder. The Customer folder is copied to the Order folder, and the catalog is closed and saved automatically.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim CatFolders as Object Dim x As Integer Set ImpApp = CreateObject("Impromptu.Application") ImpApp.CreateCatalog "GO Sample.cat", "OUTDOORS" Set ImpCat = ImpApp.ActiveCatalog set CatFolders = ImpCat.Folders ImpCat.Description = "Great Outdoors Sales Data Sample" CatFolders.AddFolder "Admin." For x = 1 To 8 CatFolders(x).CopyTo CatFolders("Admin.") Next x CatFolders("Customer").Items("Customer").CopyTo _ CatFolders("Order") ImpCat.Close End Sub

118 Automate Impromptu Using Macros

Chapter 8: Methods

CopyToClipboard Method
Syntax

ReportDocument.CopyToClipboard
Applies To

Report Document
Description

Copies selected text or pictures from the specified report to the Clipboard.
Discussion

Use the CopyToClipboard method to copy information from a text frame or a picture frame in a report to the Clipboard. Only selected text values and bitmaps in picture frames can be copied to the Clipboard using the CopyToClipboard method. If you attempt to copy any other type of report object (an entire list frame, for example), no copy is performed. The CopyToClipboard method always returns a Boolean value of 0 (FALSE) regardless of whether the selected objects were successfully copied to the Clipboard.
Return Type

Boolean
Example

This example copies the selected text of the active report to the Clipboard.
Sub Main() Dim objImpApp As Object Dim objImpRep As Object Set objImpApp = CreateObject("Impromptu.Application") Set objImpRep = objImpApp.ActiveDocument strSelectedText = objImpRep.GetSelectedText objImpRep.CopyToClipboard Set objImpRep = Nothing Set objImpApp = Nothing End Sub

Automate Impromptu Using Macros 119

Chapter 8: Methods

CreateAlias Method
Syntax

Table.CreateAlias(AliasName)
Applies To

Table
Description

Creates an alternate name for a Table object.


Discussion

The CreateAlias method will fail if a Table object is already using the name you supplied in the AliasName parameter. It will also fail if the Table object used is already an alias.
Parameters Description

AliasName

Required. Specifies the name of the Alias. Type: String

Return Type

Object
Example

The following example Creates an Alias Table for the BRANCH Table.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim DB As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\Catalogs\Sample.cat" Set ImpCat = ImpApp.ActiveCatalog Set DB = ImpCat.Databases(1) DB.Tables("BRANCH").CreateAlias "BRANCH ALIAS" Set DB = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

120 Automate Impromptu Using Macros

Chapter 8: Methods

CreateCatalog Method
Syntax

Application.CreateCatalog(Name,Database,[CatalogType], [DatabaseUserID], [DatabasePassword])


Applies To

Application
Description

Creates a new catalog with default included tables and a default user profile.
Discussion

If successful, the new catalog becomes the active one and the routine returns True. The operation will fail if another catalog is open, because only one catalog can be open at a time. By default, CreateCatalog does not create table joins. CreateCatalog duplicates the functionality of the New Catalog dialog when the "add all tables" option is used by including all the tables and columns for those tables as described in the database. In addition, it creates at least one default user profile of "creator" with all access and read/write to the catalog allowed initially. The number of profiles created is dependent on the Catalog Type created. See the Impromptu Help entry "Create a New Catalog" for other user profile implications.

Automate Impromptu Using Macros 121

Chapter 8: Methods
Parameters Description

Name Database CatalogType

Required. A string representing the name of the new Catalog. Required. A string representing the name of the Database used by the Catalog. Optional. An integer representing the type of catalog. Valid values are 0 - Personal (default) 1 - Shared 2 - Distributed 3 - Secure

DatabaseUserID

Optional. A string representing the user ID, to be used if the database requires accessverification. Optional. A string representing the user password, to be used if the database requires access-verification.

DatabasePassword

Return Type

Boolean

122 Automate Impromptu Using Macros

Chapter 8: Methods
Example

This macro creates a catalog and adds an Admin folder to it. All other folders are copied to the Admin folder. The first four lines of the macro declare variables for three objects and an integer. The application object is created and assigned to the ImpApp variable. Next, a catalog is created and attached to the OUTDOORS database. This catalog is made the active catalog. The folders of the active catalog are assigned to the CatFolders object. A description is added to the active catalog. A folder called Admin is added to CatFolders. The next statement copies the folders from CatFolders to the Admin folder. The integer variable that was declared is used in the counting statement. The Customer item from the Customer folder of the active catalog is copied to the Order folder of the same catalog. The catalog is then closed and automatically saved.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim CatFolders As Object Dim x As Integer Set ImpApp = CreateObject("Impromptu.Application") ImpApp.CreateCatalog "GO Sample.cat", "OUTDOORS" Set ImpCat = ImpApp.ActiveCatalog set CatFolders = ImpCat.Folders ImpCat.Description = "Great Outdoors Sales Data Sample" CatFolders.AddFolder "Admin." For x = 1 To 8 CatFolders(x).CopyTo CatFolders("Admin.") Next x CatFolders("Customer").Items("Customer").CopyTo _ CatFolders("Order") ImpCat.Close End Sub

Automate Impromptu Using Macros 123

Chapter 8: Methods

CreateEmptyCatalog Method
Syntax

Application.CreateEmptyCatalog(Name, [CatalogType])
Applies To Application Description

Creates a new empty catalog.


Discussion

If successful the new catalog becomes the active one and the routine returns True. CreateEmptyCatalog creates a catalog with no folders, tables, user classes, or other objects. You need to use other methods to add contents to the catalog.
Parameter Description

Name Catalog Type

Required. A string representing the name of the new Catalog. Optional. An integer representing the type of catalog being created. Valid values are 0 - Personal (default) 1 - Shared 2 - Distributed 3 - Secure

Return Type

Boolean

124 Automate Impromptu Using Macros

Chapter 8: Methods
Example

This macro creates an empty catalog and adds a catabase and one table. The first two lines declare object variables. The application object is created and assigned to ImpApp. An empty catalog is created, and it is made the active catalog. A description is added to the catalog, and a database is attached. The Branch table is added to the database. Note: You must specify a valid path and filename to use this macro.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.CreateEmptyCatalog "c:\temp\samp.cat" Set ImpCat = ImpApp.ActiveCatalog ImpCat.Description = "Great Outdoors Sales Data" ImpCat.Databases.Add("OUTDOORS") ImpCat.Databases(1).Tables.Add("BRANCH") End Sub

Automate Impromptu Using Macros 125

Chapter 8: Methods

CreateFilterFor Method
Syntax

UserClass.CreateFilterFor(ObjectToBeFiltered)
Applies To

UserClass
Description

Creates a new filter for the specified object and returns the filter for further modification.
Discussion

All objects passed as arguments to this method are added to the FilterColumns or FilteredTables collections. This method must be used before the filter expression can be set. Use the GetFilterFor method to determine the filter created by this method. An error occurs when the parameter is not a Column or Table object.
Parameters Description

ObjectToBeFiltered

Required. Specifies the Column or Table object to be filtered. Type: Object

Return Type

Object

126 Automate Impromptu Using Macros

Chapter 8: Methods
Example

The following example creates a filter for the specified column from a table in the Database.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim db as object Dim User As Object Dim Filter As Object Set ImpApp = CreateObject("Impromptu.Application") Set ImpCat = ImpApp.ActiveCatalog Set db = ImpCat.Databases("OUTDOORS") Set User = ImpCat.ActiveUserClass.UserClasses(1) Set Filter = User.CreateFilterFor _ (db.Tables("COUNTRY").Columns("COUNTRY")) With Filter .Append db.Tables("COUNTRY").Columns("COUNTRY") .Append 29 '<> .Append 1, "CAN" 'string constant .Commit End With MsgBox Filter.Formula Set db = Nothing Set User = Nothing Set Filter = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

Automate Impromptu Using Macros 127

Chapter 8: Methods

CreateSnapshot Method
Syntax

ReportDocument.CreateSnapshot
Applies To

Report Document
Description

Creates a snapshot for the specified report.


Discussion

Use the CreateSnapshot method to create a local copy of the data from the database on a PC. This is useful when direct database access is inconvenient or impossible, such as when you're going to be away from the office or when network traffic is heavy. By creating a snapshot, you create a local version of the data in the database on your PC.
Return Type

Nothing
Example

This example creates a snapshot of the active report.


Sub Main() Dim objImpApp As Object Dim objImpRep As Object Set objImpApp = CreateObject("Impromptu.Application") Set objImpRep = objImpApp.ActiveDocument objImpRep.CreateSnapshot Set objImpRep = Nothing Set objImpApp = Nothing End Sub

128 Automate Impromptu Using Macros

Chapter 8: Methods

CreateStoredProcedure Method
Syntax

Application.CreateStoredProcedure
Applies To

Application
Description

Creates a stored procedure object that you can use to define and execute a database stored procedure.
Discussion

Use the CreateStoredProcedure method to create an OLE object to define and execute database-stored procedures. This enables you to create an object that provides a common interface to database-stored procedures in different databases and on different platforms. Once you've created a stored procedure object, use the SetProcedure and the Execute methods to define and execute the specific stored procedure. You can execute stored procedures in the following databases: Informix Ingres MDI Database Gateway Net Gateway Omni SQL Server Oracle 6.x and 7.x SQL Server Sybase System 10
Return Type

Nothing

Automate Impromptu Using Macros 129

Chapter 8: Methods

DatabaseConnected Method
Syntax

Application.DatabaseConnected
Applies To

Application
Description

Returns a Boolean value based on whether the catalog is connected to its database. If the database is connected, the DatabaseConnected method returns -1 (TRUE). Otherwise, the DatabaseConnected method returns 0 (FALSE).
Return Type

Boolean

Delete Method
Syntax

Object.Delete
Applies To

Database CatalogLevel SchemaLevel Table Column FolderItem TableLink UserClass


Description

Deletes an object from the ownership collection it belongs to.


Discussion

The Delete method removes the object permanently from the ownership collection and destroys the object. To bring the object back, you must recreate the object using the Add method.
Return Type

Nothing 130 Automate Impromptu Using Macros

Chapter 8: Methods
Example

The following example demonstrates the delete method by deleting a folder item from the catalog.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\Catalogs\Sample.cat", "Creator" Set ImpCat = ImpApp.ActiveCatalog ImpCat.Folders("Order").Delete Set ImpCat = Nothing Set ImpApp = Nothing End Sub

DisconnectDatabase Method
Syntax

ReportDocument.DisconnectDatabase
Applies To

Report Document
Description

Disconnects from the database for the catalog.


Discussion

Use the DisconnectDatabase method to perform operations on the catalog itself, such as changing the folders or modifying the database definition for the catalog.
Return Type

Nothing

Automate Impromptu Using Macros 131

Chapter 8: Methods

DistributedUpdate Method
Syntax

Catalog.DistributedUpdate
Applies To

Catalog
Description

Performs Catalog update against the master Catalog.


Discussion

Use to synchronize a personal copy of a distributed master catalog with the master catalog. An error will be returned if the master catalog cannot be found, or if the catalog is not of the type Distributed.
Return Type

Nothing
Example

This macro updates a distributed catalog against the master. The first two lines declare object variables. The application object is created, and the active catalog is set to an object. The catalog is updated against the master catalog. Finally, the objects are assigned Null values to free their resources. Note: To run this macro a catalog must already be open, and the catalog must be created from a master distributed catalog.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Set ImpApp = CreateObject("Impromptu.Application") Set ImpCat = ImpApp.ActiveCatalog ImpCat.DistributedUpdate Set ImpCat = Nothing Set ImpApp = Nothing End Sub

132 Automate Impromptu Using Macros

Chapter 8: Methods

Execute Method
Syntax

StoredProcedure.Execute [Input] [,Input]...[Output] [,Output]... [ReturnValue]


Applies To

Stored Procedure
Description

Executes a database-stored procedure.


Discussion

Use the Execute method to execute a database-stored procedure that you've set up using the CreateStoredProcedure method. When you execute a stored procedure, you can: pass parameters to it. return parameters from it. return the value that's calculated by the stored procedure The Execute method returns a variant value containing the status for the stored procedure.
Parameters Description

Input Output ReturnValue

Optional. Specifies an input parameter for the stored procedure. Optional. Specifies an output parameter for the stored procedure. Optional. For stored procedures that return a value, specifies a variable that stores the returned value.

Automate Impromptu Using Macros 133

Chapter 8: Methods

Export Method
Syntax

object.Export FileName ExportFilter


Applies To

Report Document
Description

Saves the active report in a format that's usable by other applications.


Discussion

Use the Export method to save a report in a format that's usable in another application. When you use the Export method to export in ASCII format, Impromptu assigns default values to the ASCII export parameters.
Parameters Description

FileName ExportFilter

Required. Specifies the name of the exported file. Required. Specifies the file name of the export filter for the application to which you're exporting the report. The following are acceptable values for ExportFilter: Value Export Format x_ascii.flt ASCII x_dbase.flt dBASE x_excel.flt Excel x_lotus.flt Lotus

134 Automate Impromptu Using Macros

Chapter 8: Methods
Example

This macro uses the Export method to export the active report as an Ascii file. The new file will have the name of the active report with a .csv extension. Note: A report must be active.
Sub Main() 'declare variables Dim objImpApp As Object Dim objImpRep As Object Dim strFileName As String Set objImpApp = CreateObject("Impromptu.Application") 'retrieve the active report Set objImpRep = objImpApp.ActiveDocument 'get the report name and path strFileName = _ Left$(objImpRep.FullName, Len(objImpRep.FullName) - 4) 'export as an ASCII file objImpRep.Export strFileName & ".csv", "x_ascii.flt" 'release variables Set objImpRep = Nothing Set objImpApp = Nothing End Sub

Automate Impromptu Using Macros 135

Chapter 8: Methods

ExportASCII Method
Syntax

ReportDocument.ExportASCII FileName [,IncludeHeader] [,UseQuotes] [,Delimiter] [,EOL]


Applies To

Report Document
Description

Exports the specified Report Document object as a delimited ASCII file (CSV).
Discussion

Use the ExportASCII method to save a report as an ASCII file. You can then use the contents of the ASCII file in other applications that read and use ASCII files.
Parameters Description

FileName IncludeHeader

Required. Specifies the name of the exported ASCII file. Optional. Specifies a Boolean value that sets whether the report header is included in the exported file. The default is 1 (include header). Optional. Specifies a Boolean value that sets whether data items are enclosed in quotes in the exported file. The default is 1 (with quotes).

UseQuotes

136 Automate Impromptu Using Macros

Chapter 8: Methods
Parameters Description

Delimiter

Optional. Specifies a character to use as a data item delimiter in the exported file. The default is a comma. Optional. Specifies an integer value that sets the End Of Line character for the exported file. The following are acceptable values for EOL: 0 Carriage Return+Line Feed 1 Line Feed+Carriage Return 2 Carriage Return 3 Line Feed The default is 0 (Carriage Return+Line Feed).

EOL

Example

This macro uses the ExportAscii method to export the active report as an ASCII file. 'The new file will have the name of the active report with a .csv extension. Note: A report must be active.
Sub Main() 'declare variables Dim objImpApp As Object Dim objImpRep As Object Dim strASCIIFileName As String Set objImpApp = CreateObject("Impromptu.Application") 'retrieve the active report Set objImpRep = objImpApp.ActiveDocument 'get the report name and path strASCIIFileName = _ Left$(objImpRep.FullName, Len(objImpRep.FullName) - 4) 'export as an ASCII file objImpRep.ExportASCII strASCIIFileName & ".csv" 'release variables Set objImpRep = Nothing Set objImpApp = Nothing End Sub

Automate Impromptu Using Macros 137

Chapter 8: Methods

ExportdBASE Method
Syntax

ReportDocument.ExportdBASE FileName
Applies To

Report Document
Description

Exports the specified Report Document object as a dBASE file (DBF).


Discussion

Use the ExportdBASE method to save Impromptu reports as dBASE files. This allows you to create new views of the data in existing dBASE files and save them permanently as new dBASE files.
Parameters Description

FileName
Example

Required. Specifies the name of the exported dBASE file.

This macro uses the ExportdBase method to export the active report as a dBase file. The new file will have the name of the active report with a .dbf extension. Note: A report must be active.
Sub Main() 'declare variables Dim objImpApp As Object Dim objImpRep As Object Dim strdBaseFileName As String Set objImpApp = CreateObject("Impromptu.Application") 'retrieve the active report Set objImpRep = objImpApp.ActiveDocument 'get the report name and path strdBaseFileName = _ Left$(objImpRep.FullName, Len(objImpRep.FullName) - 4) 'export as a dBase file objImpRep.ExportdBase strdBaseFileName & ".dbf" 'release variables Set objImpRep = Nothing Set objImpApp = Nothing End Sub

138 Automate Impromptu Using Macros

Chapter 8: Methods

ExportExcel Method
Syntax

ReportDocument.ExportExcel FileName
Applies To

Report Document
Description

Exports the specified Report Document object as an Excel file (XLS).


Discussion

Use the ExportExcel method to save a report in a format that's usable by Microsoft Excel. Use reports saved in Excel format, as you would any other Excel file. You can also use CognosScript's OLE automation capabilities to invoke Excel and perform operations on the files you've created.
Parameters Description

FileName
Example

Required. Specifies the name that you want the exported Excel file to have.

This macro uses the ExportExcel method to export the active report as an Excel file. The new file will have the name of the active report with a .xls extension. Note: A report must be active.
Sub Main() 'declare variables Dim objImpApp As Object Dim objImpRep As Object Dim strExcelFileName As String Set objImpApp = CreateObject("Impromptu.Application") 'retrieve the active report Set objImpRep = objImpApp.ActiveDocument 'get the report name and path strExcelFileName = Left$(objImpRep.FullName, Len(objImpRep.FullName) - 4) 'export as an Excel file objImpRep.ExportExcel strExcelFileName & ".xls" 'release variables Set objImpRep = Nothing Set objImpApp = Nothing End Sub

Automate Impromptu Using Macros 139

Chapter 8: Methods

ExportHotFile Method
Syntax

ReportDocument.ExportHotFile FileName
Applies To

Report Document
Description

Exports the specified Report Document object as an Impromptu HotFile (IMS).


Discussion

Use the ExportHotFile method to save a report as an Impromptu HotFile. This is particularly useful for setting up access to information from multiple, heterogeneous databases. For example, you could use the Cognos Scheduler to execute macros that build HotFiles from several different databases overnight. Once the Hotfiles are created, you can use them to create reports containing information from all of the source databases.
Parameters Description

FileName
Example

Required. Specifies the name of the exported HotFile.

This macro uses the ExportHotfile method to export the active report as a Hotfile. The new file will have the name of the active report with a .ims extension. Note: A report must be active.
Sub Main() 'declare variables Dim objImpApp As Object Dim objImpRep As Object Dim strHotFileName As String Set objImpApp = CreateObject("Impromptu.Application") 'retrieve the active report Set objImpRep = objImpApp.ActiveDocument 'get the report name and path strHotFileName = _ Left$(objImpRep.FullName, Len(objImpRep.FullName) - 4) 'export as a HotFile objImpRep.ExportHotFile strHotFileName & ".ims" 'release variables Set objImpRep = Nothing Set objImpApp = Nothing End Sub

140 Automate Impromptu Using Macros

Chapter 8: Methods

ExportLotus Method
Syntax

ReportDocument.ExportLotus FileName
Applies To

Report Document
Description

Exports the specified Report Document object as a Lotus file (WKn).


Discussion

Use the ExportLotus method to save a report in a format that's usable by Lotus 123. Once you've saved reports in Lotus format, you can use them as you would any other Lotus file. You can also use CognosScript's OLE automation capabilities to invoke Lotus and perform operations on the files you've created.
Parameters Description

FileName
Example

Required. Specifies the name of the exported Lotus file.

This macro uses the ExportLotus method to export the active report as a Lotus file. The new file will have the name of the active report with a .wkn extension. Note: A report must be active.
Sub Main() 'declare variables Dim objImpApp As Object Dim objImpRep As Object Dim strLotusFileName As String Set objImpApp = CreateObject("Impromptu.Application") 'retrieve the active report Set objImpRep = objImpApp.ActiveDocument 'get the report name and path strLotusFileName = Left$(objImpRep.FullName, Len(objImpRep.FullName) - 4) 'export as a Lotus file objImpRep.ExportLotus strLotusFileName & ".wkn" 'release variables Set objImpRep = Nothing Set objImpApp = Nothing End Sub

Automate Impromptu Using Macros 141

Chapter 8: Methods

ExportData Method
Syntax

ReportDocument.ExportData FileName
Applies To

Report Document
Description

Exports the specified Report Document object as a PowerPlay data file (DAT).
Discussion

Use the ExportData method to save a report as a PowerPlay data definition file. Once you've saved a report as a PowerPlay file, you can use PowerPlay to perform drill-down operations on the data contained in the file.
Parameters Description

FileName
Example

Required. Specifies the name of the exported PowerPlay data file.

This macro uses the ExportData method to export the active report as a PowerPlay data file. The new file will have the name of the active report with a .dat extension. Note: A report must be active.
Sub Main() 'declare variables Dim objImpApp As Object Dim objImpRep As Object Dim strPPFileName As String Set objImpApp = CreateObject("Impromptu.Application") 'get the current report Set objImpRep = objImpApp.ActiveDocument 'get the report name and path strPPFileName = _ Left$(objImpRep.FullName, Len(objImpRep.FullName) - 4) 'export as a PowerPlay data file objImpRep.ExportData strPPFileName & ".dat" 'release variables Set objImpRep = Nothing Set objImpApp = Nothing End Sub

142 Automate Impromptu Using Macros

Chapter 8: Methods

ExportSQL Method
Syntax

ReportDocument.ExportSQL FileName
Applies To

Report Document
Description

Exports the current query as a Structured Query Language file (SQL).


Discussion

You can use the SQL statements that Impromptu generates in other database query applications that support SQL. Note: Impromptu uses application-specific SQL when processing occurs on the PC. If you intend to use Impromptu's SQL statements in other applications, you can ensure that generated SQL statements are portable by setting all processing to occur on the server. See Adjusting the Client/ Server Balance in the main Impromptu help file.
Parameters Description

FileName
Example

Required. Specifies the name that you want the exported SQL file to have.

This macro uses the ExportSQL method to export the active report as a SQL file. The new file will have the name of the active report with a .sql extension. Note: A report must be active.
Sub Main() 'declare variables Dim objImpApp As Object Dim objImpRep As Object Dim strSQLFileName As String Set objImpApp = CreateObject("Impromptu.Application") 'get the current report Set objImpRep = objImpApp.ActiveDocument 'get the report name and path strSQLFileName = _ Left$(objImpRep.FullName, Len(objImpRep.FullName) - 4) 'export as a SQL file objImpRep.ExportSQL strSQLFileName & ".sql" 'release variables Set objImpRep = Nothing Set objImpApp = Nothing End Sub

Automate Impromptu Using Macros 143

Chapter 8: Methods

ExportText Method
Syntax

ReportDocument.ExportText FileName
Applies To

Report Document
Description

Exports the specified Report Document object as a Text file (TXT).


Discussion

Use the ExportText method to save the data in a report as a text file. Impromptu automatically includes header information in the text file, and it aligns data values under the appropriate item name in the header. You can then use the contents of the text file in other applications.
Parameters Description

FileName
Example

Required. Specifies the name of the exported Text file.

This macro uses the ExportText method to export the active report as a Text file. The new file will have the name of the active report with a .txt extension. Note: A report must be active.
Sub Main() 'declare variables Dim objImpApp As Object Dim objImpRep As Object Dim strTextFileName As String Set objImpApp = CreateObject("Impromptu.Application") 'get the current report Set objImpRep = objImpApp.ActiveDocument 'get the report name and path strTextFileName = Left$(objImpRep.FullName, Len(objImpRep.FullName) - 4) 'export as a Text file objImpRep.ExportText strTextFileName & ".txt" 'release variables Set objImpRep = Nothing Set objImpApp = Nothing End Sub

144 Automate Impromptu Using Macros

Chapter 8: Methods

ExportTransformer Method
Syntax

ReportDocument.ExportTransformer FileName
Applies To

Report Document
Description

Exports the active report as a PowerPlay Transformer file (IQD).


Discussion

Use the ExportTransformer method to save a report for use with PowerPlay Transformer. PowerPlay Transformer can read the IQD file and transform it into files that can be used in PowerPlay Explorer and PowerPlay Reporter.
Parameters Description

FileName
Example

Required. Specifies the name for the exported PowerPlay Transformer file.

This macro uses the ExportTransformer method to export the active report as an IQD file. The new file will have the name of the active report with a .iqd extension. Note: A report must be active.
Sub Main() 'declare variables Dim objImpApp As Object Dim objImpRep As Object Dim strIQDFileName As String Set objImpApp = CreateObject("Impromptu.Application") 'get the current report Set objImpRep = objImpApp.ActiveDocument 'get the report name and path strIQDFileName = _ Left$(objImpRep.FullName, Len(objImpRep.FullName) - 4) 'export as IQD file (as the name of the report with iqd extension) objImpRep.ExportTransformer strIQDFileName & ".iqd" 'release variables Set objImpRep = Nothing Set objImpApp = Nothing End Sub

Automate Impromptu Using Macros 145

Chapter 8: Methods

FileSetPrinter Method
Syntax

Application.FileSetPrinter PrinterName
Applies To

Application
Description

Sets the default printer for Impromptu reports.


Discussion

Use the FileSetPrinter method to change the printer that Impromptu uses when printing reports. For example, you can use the FileSetPrinter method to print a single report on multiple printers, each of which is located in a different area of your company. Make sure that the value you specify for PrinterName matches exactly (including the case) the device name that's listed in the [Devices] section of the WIN.INI file. In general, this should be the name of the printer as it's displayed in Print Manager, up to but not including the "on <port number>" qualifier. For example, if you see the following printer description in Print Manager:
HP LaserJet 4Si/4SiMX PS 300dpi on LPT1 [\\OTRS1\OTR6C1]

To select this printer in a macro, enter for PrinterName as: HP LaserJet 4Si/4SiMX PS 300dpi
Parameters Description

PrinterName

Required. Specifies the name of the printer (as displayed in Print Manager without the connection suffix on <connection>) that Impromptu uses when printing reports. Note: PrinterName must match exactly the strings that are registered in the WIN.INI file under the [Devices] section. PrinterName is case-sensitive. For example, the string "Postscript Printer" does not match "PostScript Printer".

146 Automate Impromptu Using Macros

Chapter 8: Methods
Example

This example is changing from the default printer to another one in order to print a specific report, and then changing back to the default printer again. You must use your own available printers.
Sub Main() Dim objImpApp As Object Dim objImpRep As Object Set objImpApp = CreateObject("Impromptu.Application") objImpApp.FileSetPrinter "HP LaserJet 5P/5MP PostScript" Set objImpRep = objImpApp.OpenReport("C:\Cognos\Samples\" & _ "Reports\All Country Sales.imr") objImpRep.Print ' set the printer back to the default objImpApp.FileSetPrinter "HP LaserJet 4Si/4SiMX PS" Set objImpRep = Nothing Set objImpApp = Nothing End Sub

Automate Impromptu Using Macros 147

Chapter 8: Methods

GenerateReport Method
Syntax

Applicationt.GenerateReport Catalog ,DataBase ,[HostDatabase] ,[DatabaseOwner] ,Table ,Template ,[ReportName] ,[UserClassID] ,[UserClassPassword] ,[DatabaseID] ,[DatabasePassword]
Applies To

Application
Description

Automatically creates, formats, and saves an Impromptu report for a specific table in a database, or a HotFile.
Discussion

Use the GenerateReport method to automatically create reports for entire tables in both databases and HotFiles. Because GenerateReport can use tables from both HotFiles and databases, it can automatically gather information from multiple databases and servers into a single report. When the Cognos Scheduler executes a macro that runs an Impromptu report, the Scheduler passes Impromptu all security information required by both Impromptu and the database.

148 Automate Impromptu Using Macros

Chapter 8: Methods
Parameters Description

Catalog

Required. Specifies the name of the Impromptu catalog containing the table for which you're generating a report. Required. Specifies the Impromptu logical database name or the HotFile name containing the table for which you're generating a report. Required for databases that support multiple databases on a single server. For Sybase databases, HostDatabase is the database name. It specifies the name of the database containing the DatabaseOwner and Table for which you're generating a report. Required only for databases that support owners. For Oracle and Sybase databases, DatabaseOwner is the owner name. Required. Specifies the name of the table for which you're generating a report. Required. Specifies the file name of a template used to apply formatting to the generated report. Optional. Allows you ti specify a file name for the generated report. If no ReportName is specified, Impromptu assigns a name.

DataBase

HostDatabase

DatabaseOwner

Table Template

ReportName

UserClassID UserClassPassword DatabaseID DatabasePassword

Optional. Required only if the catalog is not open. Optional. Required only if the catalog is not open. Optional. Required only if the catalog is not open and the database supports multiple users. Optional. Required only if the catalog is not open and the database supports multiple users.

Automate Impromptu Using Macros 149

Chapter 8: Methods
Example

This example generates a report from the table specified. The report is based on the specified template.
Sub Main() Dim objImpApp As Object Dim objImpRep As Object Const catalog = _ "C:\Cognos\Samples\Reports\Great Outdoors Sales Data.CAT" Const database = "OUTDOORS" Const table = "BRANCH" Const template = "C:\Cognos\Samples\Templates\Standard\Simple List.imt" Const report = "C:\Cognos\Samples\Reports\branch.imr" Set objImpApp = CreateObject("Impromptu.Application") objImpApp.GenerateReport _ catalog, database, , , table, template, report objImpApp.CloseCatalog objImpApp.Quit Set objImpRep = Nothing Set objImpApp = Nothing End Sub

GetAppVersionInfo Method
Syntax

Application.GetAppVersionInfo([Major,[Minor,[Build,[Services]]]])
Applies To

Application
Description

Returns version information for Impromptu applications.


Discussion

Use this method to retrieve version information about an Impromptu application. Each parameter adds a level of detail to the information returned major release minor release build service When using parameters, each must be a defined variable, not a hardcoded integer or string, and you must include them from left to right. For example, you can't include Services without also including Major, Minor and Build.

150 Automate Impromptu Using Macros

Chapter 8: Methods When no parameters are included, an integer value representing Major, Minor and Build is returned by default. In this case, if the Build value includes a decimal, it will be lost. The following example returns all version information:
Dim Version As Long Dim Major As String, Minor As String, Build as String, Services As String Version = ImpApp.GetAppVersionInfo(Major, Minor, Build, Services)

The returned information looks something like this: Major = 5 Minor = 1 Build = 133 Services = R97K This translates into version 5.1, build 133, DMS service R97K.
Parameter Description

Major Minor Build Services


Return Type

Optional: A variable of type Long, Integer or String giving the major version number. Optional: A variable of type Long, Integer or String giving the minor version number. Optional: A variable of type Long, Integer or String giving the build number. Optional: A variable of type String giving the full DMS service release string.

Long

Automate Impromptu Using Macros 151

Chapter 8: Methods

GetDataValue Method
Syntax

ReportDocument.GetDataValue(Column, Row)
Applies To

Report Document
Description

Returns a string that contains a data value from a cell in the active query.
Discussion

Use the GetDataValue method to assign a specific value in a query to a variable. The value returned is always stored as a string. You can use conversion functions to convert the string to another datatype, if required. To get the data value from the first row and first column in the query, use (1,1). Note: The values for Column and Row refer to a column and row in the active query, not in a list frame. You can use the GetDataValue method to return a specific value from any type of report.
Parameters Description

Column Row

Required. Specifies the column number in the query from which to select a value. Required. Specifies the row number in the query from which to select a value.

Example

This example displays a string containing the data value in the interesecting cell of column 2 and row 3.
Sub Main() Dim objImpApp As Object Dim objImpRep As Object Dim strReturnValue As String Set objImpApp = CreateObject("Impromptu.Application") Set objImpRep = objImpApp.ActiveDocument strReturnValue = objImpRep.GetDataValue(2,3) MsgBox strReturnValue Set objImpRep = Nothing Set objImpApp = Nothing End Sub

152 Automate Impromptu Using Macros

Chapter 8: Methods

GetErrorNumber Method
Syntax

Application.GetErrorNumber
Applies To

Application
Description

Returns an OLE automation error number from Impromptu.


Discussion

As CognosScript macros and OLE automation scripts written in other applications run, you can use the GetErrorNumber method to trap errors as they occur. The following table lists the error numbers and their associated errors:
Error No Description

24577 24578 24579 24580

An error has occurred during execution of the query. The stored procedure name has to be initialized first. Parameter number <parm> type is not supported. Syntax error. The char descriptor has to be one of VarChar, Char, or LongVarChar. Stored procedure has to be executed first. The user class password is not correct. Out of memory. Parameter <parm> is invalid. Catalog is not distributed. Cannot update. Update failed due to internal error. Contact Cognos customer support. Current catalog specifies a master catalog which is not an Impromptu catalog.

24581 24582 24583 24584 24585 24587 24588

Automate Impromptu Using Macros 153

Chapter 8: Methods
Error No Description

24589 24590 24591 24592 24593 24594 24595 24596 24597 24598 24599 24600 24601

Could not open the master catalog for update. Master catalog is from an incompatible version. Catalog method called when no catalog was open. No valid selection for this operation. This catalog could not be found. (<catalogname>) Unable to open this catalog. (<catalogname>) Table name parameter is empty. Specified table was not found. Unable to generate default report. This template could not be found. (<templatename>) Report could not be opened. Current catalog is read-only. Unable to add table <Database><HostDatabase><DBOw ner><TableName>. Database name is invalid. Could not connect to database due to wrong or insufficient information provided. Login error while connecting to the database. Database is already connected. Login error: <errortype> Cannot convert to a snapshot report. This report cannot be converted to access the database. Invalid printer name. The printer driver is not installed. Extended device mode is not supported with this driver.

24602 24603

24604 24605 24606 24609 24610 24611 24612 24613

154 Automate Impromptu Using Macros

Chapter 8: Methods
Error No Description

24614 24615 24616

The driver could not get the size of the initialization buffer. The report cannot be edited Multiple errors have occured with Impromptu. Use GetNextQueryError method to retrieve the error information. User class restriction. The report can not be created. *** Unknown Error Type *** Impromptu cannot open the catalog. Impromptu could not connect to the database.

24617 24618 24641 24642


Return Type

Integer
Example

This example attempts to open a catalog using an invalid path. The error number returned will be displayed in a message box.
Sub Main() Dim objImpApp As Object On Error GoTo ErrorHandler Set objImpApp = CreateObject("Impromptu.Application") objImpApp.OpenCatalog "C:\Samples\Impromptu\Reports\" & _ "GREAT OUTDOORS SALES DATA.CAT" ErrorHandler: msgbox objImpApp.GetErrorNumber resume done done: Set objImpApp = Nothing End Sub

Error 24577 An error has occurred during execution of the query.

An error condition has been detected during the execution of the current query. The content of this message will vary depending on the nature of the problem.

Automate Impromptu Using Macros 155

Chapter 8: Methods
Error 24578 The stored procedure name has to be initialized first.

You've attempted to execute a stored procedure before you've set the procedure name. Use the SetProcedure method to set the name of the stored procedure.
Error 24579 Parameter number <type> type is not supported.

You've specified an invalid parameter type for a stored procedure parameter.


Error 24580 Syntax error the char descriptor has to be VarChar, Char, or LongVarChar.

You've specified an invalid descriptor for a variable length parameter of a stored procedure. Specify either VarChar[n], Char[n], or LongVarChar[n], where n indicates the maximum size for the variable length parameter. See the SetProcedure method.
Error 24581 Stored procedure has to be executed first.

You've attempted to obtain the value of an output parameter before you've exected the stored procedure. Use the Execute method to execute the stored procedure.
Error 24582 The user class password is not correct.

You've specified an invalid user class password. Ensure that the user class password is valid.
Error 24583 Out of memory.

The OLE automation procedure has run out of memory. Try closing some applications and running the automation script again.

156 Automate Impromptu Using Macros

Chapter 8: Methods
Error 24584 Parameter <parm> is invalid.

You've specified an invalid parameter as the input to a method. For example, Impromptu has encountered a Boolean value for a parameter when a string value is expected. Make sure that you've specified the parameters correctly. Ensure that you also provide a comma to delimit each parameter when omitting values for some parameters.
Error 24585 Cannot update. Catalog is not distributed.

You've tried to use the UpdateCatalog method to obtain the latest changes for a catalog. The UpdateCatalog method is valid only for distributed catalogs, not for personal, shared, or secured catalogs.
Error 24587 Update failed due to internal error. Contact customer support.

CognosScript has encountered a fatal internal error. Please call your local Cognos support centre. See Cognos Customer Support Centers.
Error 24588 Current catalog specifies a master catalog which is not an Impromptu Catalog.

When attempting to update your local copy of a distributed catalog, Impromptu has encountered a problem with the master catalog.
Error 24589 Could not open the master catalog for update.

The UpdateCatalog method could not open the master catalog. Make sure that you have the necessary LAN access, and that the master catalog exists and is intact.
Error 24590 Master catalog is an incompatible version.

During an UpdateCatalog, the master catalog could not be opened because it was created with an earlier version of Impromptu. Contact your database administrator.

Automate Impromptu Using Macros 157

Chapter 8: Methods
Error 24591 Catalog method called when no catalog was open.

You've attempted to call a method that operates on a catalog when no catalog is currently open. Use the OpenCatalog method to open a catalog before using methods such as ChangeUserClass, ConnectDatabase, CloseCatalog, UpdateCatalog, or AddTable.
Error 24592 No valid selection for this operation.

The GetSelectedText method has not found any valid selected text. Use this error to trap whether an Impromptu user has selected text prior to launching a macro that uses the GetSelectedText method.
Error 24593 This catalog could not be found. <catalogname>

A catalog name specified in a method could not be found. Ensure that the name is specified correctly, and that you have read access to it.
Error 24594 Unable to open this catalog. <catalogname>

A catalog that you've specified in either the OpenCatalog method or or GenerateReport method could not be opened. Ensure that the name is specified correctly, and that you have read access to it.
Error 24595 Table name parameter is empty.

You have not specified a value for theTable from within either the GenerateReport method or the AddTable method.
Error 24596 Specified table was not found.

Within the GenerateReport method or the AddTable method, the specified Table could not be found. Ensure that you've specified the correct name for the table.
Error 24597 Unable to generate default report.

Login or table information is valid, however, the GenerateReport method is unable to generate a default report. Ensure that the template name is specified correctly. Ensure also that the method didn't try to create the report on a full disk, and that the name specified for the report doesn't already exist. 158 Automate Impromptu Using Macros

Chapter 8: Methods
Error 24598 This Template could not be found. <templatename>

The ApplyTemplate method could not locate the specified template. Ensure that you've specified the correct name for the template and that you have the necessary LAN access to it.
Error 24599 Report could not be opened.

The OpenReport method could not locate the specified Impromptu report. Ensure that you've specified the correct name for the report and that you have the necessary LAN access to it.
Error 24600 Current catalog is read-only.

You've attempted to make changes to the current catalog with the UpdateCatalog method. Check that the catalog file (CAT) is not readonly.
Error 24601 Unable to add table <Database><HostDatabase><DBOwner><TableName>.

The AddTable method was unable to add the specified table. Ensure that the database (Impromptu logical database name), HostDatabase (Host database name), DBOwner (host database owner), and TableName are all specified correctly. Ensure also that your connection to the database is active.
Error 24602 Database name is invalid.

The AddTable method has detected an invalid database name. Ensure that the database (Impromptu logical database name) name is specified correctly.
Error 24603 Wrong or insufficient information provided. Could not connect database.

In the ConnectDatabase method, the information provided was not sufficient to connect the database. Ensure that you've provided all of the required parameters (user ID, password).

Automate Impromptu Using Macros 159

Chapter 8: Methods
Error 24604 Login error while connecting the database.

In the ConnectDatabase method, an error other than a security error occurred during an attempt to connect to the database.
Error 24605 Database is already connected.

You've used the ConnectDatabase method when the catalog is already connected to its associated database.
Error 24606 Login error. <errortype>

In the ConnectDatabase method, the user ID and password are specified incorrectly or are not sufficient for the current level of security.
Error 24609 Cannot convert to a snapshot report.

The CreateSnapshot method is unable to save the current report as a snapshot. Ensure that your disk has sufficient space to store a snapshot of the report data.
Error 24610 This report cannot be converted to access the database.

The current report cannot revert to database access from a snapshot. Ensure that the connection to the database is active.
Error 24611 Invalid printer name.

You have specified the name of a printer that does not exist in the FileSetPrinter method. Make sure that the value specified for PrinterName matches exactly (including the case) the device name that's listed in the [Devices] section of your WIN.INI file. In general, this should be the name of the printer as it's displayed in Print Manager, up to but not including the "on <port number>" qualifier.
Error 24612 The printer driver is not installed.

Windows is unable to locate the printer driver for the printer that you've specified in the FileSetPrinter method. Ensure that the printer driver is installed correctly.

160 Automate Impromptu Using Macros

Chapter 8: Methods
Error 24613

Extended device mode is not supported with this driver.


Error 24614

The driver could not get the size of the initialization buffer.
Error 24615

The report cannot be edited.


Error 24616

Multiple errors have occured with Impromptu. Use GetNextQueryError() method to retrieve the error information. The current report cannot execute because of query errors. Use the GetNextQueryError method to return the error number(s) and description.
Error 24617 User class restriction. The report can not be created.

A user class restriction, such as being prohibited from accessing a specific table or folder, is preventing the current report from executing successfully. Ensure that the restrictions for the current user class do not conflict with the report requirements.
Error 24618 *** Unknown Error Type ***

Impromptu has encountered an unexpected error. Contact Cognos Customer Support.


Error 24641 Impromptu cannot open the required catalog.

The required catalog cannot be open. Ensure you have specified the correct catalog name.
Error 24642 Impromptu could not connect to the database.

Ensure that the correct database has been specified.

Automate Impromptu Using Macros 161

Chapter 8: Methods

GetFilterFor Method
Syntax

UserClass.GetFilterFor(FilteredObject)
Applies To

UserClass
Description

Returns the filter expression (if one exists) for the input object.
Discussion

If the object contains no filter, Nothing is returned. An error occurs when the parameter is not a Column or Table object. If the filter expression exists for the Column or Table object, the object will be a member of the FilteredColumns or FilteredTables collection.
Parameters Description

FilteredObject

Required. Specifies the Column or Table object whose filter you want to determine. Type: Object

Return Type

Object
Example

The following example returns the filter for the specified column.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim db as object Dim User As Object Dim Filter As Object Set ImpApp = CreateObject("Impromptu.Application") Set ImpCat = ImpApp.ActiveCatalog Set db = ImpCat.Databases("OUTDOORS") Set User = ImpCat.ActiveUserClass.UserClasses(1) Set Filter = _ User.GetFilterFor (db.Tables("COUNTRY").Columns("COUNTRY")) MsgBox Filter.Formula Set db = Nothing Set User = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

162 Automate Impromptu Using Macros

Chapter 8: Methods

GetNextQueryError Method
Syntax

Application.GetNextQueryError
Applies To

Application
Description

Returns the next query error in the current macro.


Discussion

The GetNextQueryError method returns a string that contains the number and associated text for an Impromptu query error. When a query error is detected, it raises the error number 24616, indicating that some type of query error has occurred. When occurs, use the GetNextQueryError method to return query error numbers along with their descriptions. Query Errors fall into the following categories:
Error Range Error Type

100 to 299

Critical errors. These can occur at either compiletime or runtime, depending on the nature of the error. Warnings. These are ignored unless the UseQueryWarnings property is set to 1. Critical runtime errors.

300 to 499 500 or greater

The following list describes briefly the errors returned using the GetNextQueryError method:
Error String

100: Cannot execute query. Processing requirements exceed the current Client/Server limits. 101: Data item [%1] could not be found. 102: Data item [%1] is invalid because [%2] could not be found. 103: Using the Governor denied Database Column [%1]. 104: This report will result in a 'cross product' query. This User Profile prevents the use of 'cross product' reports. 105: The query for this report contains an 'outer join'. This User Profile prevents the use of 'outer join' queries.

Automate Impromptu Using Macros 163

Chapter 8: Methods
Error String

106: This report sorts on the non-indexed columns. 107: This report contains circular [DATASET] references: %1. 108: This report contains a prompt nested within a sub-report: %1. 109: This report uses %1 tables. This exceeds the current Governor restriction of %2 tables for a report. 110: Data item [%1] is invalid because it contains additional invalid Data Items. 111: Invalid SQL query. Use read-only SELECT statements. 112: Prompt uses column %1 of report %2 which doesn't exist. 113: Prompt displays column %1 of report %2 which doesn't exist. 300: This report is expected to use %1 tables. 301: This report is expected to return %1 rows. 302: The expected report preparation time is %1. 303: This report suppresses duplicates. 304: This report will result in a 'cross product' query. 305: This report sorts on the non-indexed columns. 306: The query for this report contains an 'outer join'. 307: This crosstab report contains a query column, %1, that no longer exists. 308: This crosstab report contains a bad reference to %2 in a conditional format. 309: This crosstab report contains a bad reference in %1 to %2. 310: This crosstab report contains a bad reference to %2 in the detail filter. 311: This crosstab report contains a bad reference to %2 in the summary filter. 500: This report exceeded the current Governor Restriction of %1 report preparation time. 501: Database Retrieval Limit reached. Governor restrictions specify a retrieval limit of %1 rows for the current User Profile. 502: Could not open the following [DATASET] report: %1.
Return Type

String

164 Automate Impromptu Using Macros

Chapter 8: Methods
Example

The following example traps Impromptu query errors in sequence and displays a message box for each one that appears. If opening the report causes a query error (for example, it references a table or column to which the admin user class is denied access), the macro will display a series of error messages in message boxes until all of the query errors have been returned.
sub main Dim impp As object Dim rep As object On Error goto HndlErr 'create an Impromptu 4.0 application object Set impp = CreateObject("Impromptu.Application") 'make Impromptu visible impp.visible 1 'make Impromptu treat query warnings as errors impp.UseQueryWarnings 1 'open the SYBASE.CAT catalog, user class = admin, 'admin password = admin_pwd, 'database User ID=qcimprom, 'database password=qcimprom 'connect to database while opening catalog impp.opencatalog _ "sybase.cat","admin","admin_pwd","qcimprom","qcimprom",1 'open the SYBASE01.IMR report set rep = impp.OpenReport("sybase01.imr") HndlErr: do serr = impp.GetNextQueryError if serr <> "" then msgbox serr else exit do end if loop resume next end sub

Query Error 100 Cannot execute query. Processing requirements exceed the current Client/Server limits.

The current report exceeds one or more of the client/server limits imposed in the Client/Server tab-Query dialog box. For example, the report uses a local Impromptu function when client/server load balancing is set to database only. Ensure that the client/server settings meet the requirements of the report.
Query Error 101 Data item [%1] could not be found.

A data item used in the current report is invalid because Impromptu is unable to locate it's associated column. Automate Impromptu Using Macros 165

Chapter 8: Methods
Query Error 102 Data item [%1] is invalid because [%2] could not be found.

A data item used in the current report is invalid because Impromptu is unable to locate the catalog expression upon which it is based. Ensure that the data items in the report do not depend on catalog calculations that no longer exist.
Query Error 103 Using the Governor denied Database Column [%1].

The current report cannot execute because of a report governor restriction. Ensure that the current user class has sufficient access to all of the tables, folders, and columns in the catalog.
Query Error 104 This report will result in a 'cross product' query. This User Profile prevents the use of 'cross product' reports.

The current report cannot execute because of a report governor restriction that prevents cross-product reports. Ensure that the current user class has sufficient privilege to execute cross product reports, or change the user class restrictions.
Query Error 105 The query for this report contains an 'outer join'. This User Profile prevents the use of 'outer join' queries.

The current report cannot execute because of a report governor restriction that prevents the use of outer joins. Ensure that the current user class has sufficient privilege to use outer joins, or change the user class restrictions.
Query Error 106 This report sorts on the non-indexed columns.

The current report cannot execute because of a report governor restriction that prevents sorting on non-indexed columns. Ensure that the current user class has sufficient privilege to sort on non-indexed columns, or change the user class restrictions.
Query Error 107 This report contains circular [DATASET] references %1.

The current report cannot execute because a dataset used within an expression contains a reference to itself. Ensure that the datasets used in the report do not contain any references to themselves.

166 Automate Impromptu Using Macros

Chapter 8: Methods
Query Error 108 This report contains a prompt nested within a sub-report %1.

The current report cannot execute because a dataset used within an expression contains a runtime prompt (either a pick-list or type-in). Ensure that the datasets used within expressions in the report do not contain any runtime prompts.
Query Error 109 This report uses %1 tables. This exceeds the current Governor restriction of %2 tables for a report.

The current report cannot execute because it accesses more tables than are currently allowed by the report governor for the current user class. Ensure that the current user class has sufficient privilege to access the required number of tables, or change the user class restrictions.
Query Error 110 Data item [%1] is invalid because it contains additional invalid Data Items.

The current report contains an expression that Impromptu has tagged as invalid. If you encounter this error, contact Cognos Customer Support.
Query Error 111 Invalid SQL query. Use read-only SELECT statements.

This message occurs only if you've manually edited the SQL statements for the current query using the SQL Query dialog box. Impromptu supports only SELECT statements. Impromptu returns this message if you enter an invalid SQL statement, or if you attempt to enter a read/ write statement (such as INSERT, DROP TABLE, or CREATE TABLE, for example). Verify that manually entered SQL statements are valid.
Query Error 112 Prompt uses column %1 of report %2 which doesn't exist.

A runtime prompt (either a catalog Picklist or a report Picklist) within a report you're trying to run contains a reference to a column that Impromptu cannot find. Ensure that the column used to filter data in the Picklist exists in the database.
Query Error 113 Prompt displays column %1 of report %2 which doesn't exist.

A runtime prompt (either a catalog Picklist or a report Picklist) within a report you're trying to run contains a reference to a column that Impromptu cannot find. Ensure that the column used to display filter data in the Picklist exists in the database.

Automate Impromptu Using Macros 167

Chapter 8: Methods
Query Error 300 This report is expected to use %1 tables.

The report you're running is going to use more tables than the current warning level allows. Either change the Governor settings for the current user class so that the warning level allows more tables, or tell Impromptu to ignore warning messages by setting the UseQueryWarnings property to 0. Note: This error is ignored unless the UseQueryWarnings property is set to 1.
Query Error 301 This report is expected to return %1 rows.

The report you're running is going to use more rows than the current warning level allows. Either change the Governor settings for the current user class so that the warning level allows more rows, or tell Impromptu to ignore warning messages by setting the UseQueryWarnings property to 0. Note: This error is ignored unless the UseQueryWarnings property is set to 1.
Query Error 302 The expected report preparation time is %1.

The report you're running requires more time to execute than the current warning level allows. Either change the Governor settings for the current user class so that the warning level allows more execution time, or tell Impromptu to ignore warning messages by setting the UseQueryWarnings property to 0. Note: This error is ignored unless the UseQueryWarnings property is set to 1.
Query Error 303 This report suppresses duplicates.

Impromptu has issued a warning for the current user class because the current query supresses duplicates and the Governor is set to warn the user when this occurs. Either change the Governor settings for the current user class so that the suppression of duplicates is allowed or tell Impromptu to ignore warning messages by setting the UseQueryWarnings property to 0. Note: This error is ignored unless the UseQueryWarnings property is set to 1.

168 Automate Impromptu Using Macros

Chapter 8: Methods
Query Error 304 This report will result in a 'cross product' query.

The Governor warns the user when the current query generates a crossproduct. Either change the Governor settings for the current user class so that cross-product queries are allowed or tell Impromptu to ignore warning messages by setting the UseQueryWarnings property to 0. Note: This error is ignored unless the UseQueryWarnings property is set to 1.
Query Error 305 This report sorts on the non-indexed columns.

Governor warns the user when the current query sorts on non-indexed columns. Either change the Governor settings for the current user class so that sorting on non-indexed columns is allowed or tell Impromptu to ignore warning messages by setting the UseQueryWarnings property to 0. Note: This error is ignored unless the UseQueryWarnings property is set to 1.
Query Error 306 The query for this report contains an 'outer join'.

The Govenor warns the user when the current query uses an outer join. You can change the Governor settings for the current user class so that outer joins are allowed, or tell Impromptu to ignore warning messages by setting the UseQueryWarnings property to 0. Note: This error is ignored unless the UseQueryWarnings property is set to 1.
Query Error 307 This crosstab report contains a query column (%1) that no longer exists.

A crosstab report contains a reference to a column that Impromptu cannot locate. Ensure that the column has not been deleted from the database or renamed. Note: This error is ignored unless the UseQueryWarnings property is set to 1.

Automate Impromptu Using Macros 169

Chapter 8: Methods
Query Error 308 This crosstab report contains a bad reference to %2 in a conditional format.

A crosstab report that uses conditional formatting contains an invalid reference to a data item within the conditional format. Ensure that the columns and data items used in a conditional format exist within the catalog. Note: This error is ignored unless the UseQueryWarnings property is set to 1.
Query Error 309 This crosstab report contains a bad reference in %1 to %2.

A crosstab report uses a calculation that contains an invalid reference to a data item. Ensure that the columns used in calculated data items exist within the catalog. Note: This error is ignored unless the UseQueryWarnings property is set to 1.
Query Error 310 This crosstab report contains a bad reference to %2 in the detail filter.

A crosstab report that filters detail data contains an invalid refrence to another column or data item. Ensure that the columns and data items used in the detail filter exist within the catalog. Note: This error is ignored unless the UseQueryWarnings property is set to 1.
Query Error 311 This crosstab report contains a bad reference to %2 in the summary filter.

A crosstab report that filters summary data contains an invalid reference to another column or data item. Ensure that the columns and data items used in the summary filter exist within the catalog. Note: This error is ignored unless the UseQueryWarnings property is set to 1.
Query Error 500 This report exceeded the current Governor restriction of %1 report preparation time.

A report has exceeded the maximum time allowed to complete the execution of a query. Either change the Governor settings for the current user class so more time is allowed for the query, or assign a user class with sufficient privileges to execute the report. 170 Automate Impromptu Using Macros

Chapter 8: Methods
Query Error 501 Database Retrieval Limit reached. Governor restrictions specify a retrieval limit of %1 rows for the current User Profile.

A report has exceeded the maximum number of rows allowed for a query. Either change the Governor settings for the current user class so more rows can be retrieved by the query, or assign a user class with sufficient privileges to execute the report.
Query Error 502 Could not open the following [DATASET] report %1.

Impromptu has been unable to locate a dataset report that's used in the filter for the current report. Ensure that the dataset report exists, and that it's located in a directory to which you have read access.

GetParameter Method
Syntax

StoredProcedure.GetParameter(n)
Applies To

Stored Procedure
Description

Returns the value from the nth parameter for a stored procedure.
Discussion

Use the GetParameter method to return parameter values from stored procedures. Ensure that the variables assigned are of the correct type and size to hold the value returned by GetParameter.
Parameters Description

Required. Specifies the parameter (output or input) within the syntax of the stored procedure call. Setting n to 1 returns the value of the first parameter; setting n to 2 returns the value of the second parameter; and so on.

Automate Impromptu Using Macros 171

Chapter 8: Methods

GetSelectedText Method
Syntax

ReportDocument.GetSelectedText
Applies To

Report Document
Description

Returns a string value containing currently selected text in the active report.
Discussion

Use the GetSelectedText method to assign the value of selected text in an Impromptu report to a string variable. Use this method when launching a macro which operates on selected text. For example, you could select a summary value for total sales over a given period, and then launch a macro that compares the selected value to previous sales totals.
Return Type

String
Example

This example copies the selected text of the active report to the Clipboard. If it's succesful a message will be displayed. A report must be active and a selection must be made.
Sub Main() Dim objImpApp As Object Dim objImpRep As Object Set objImpApp = CreateObject("Impromptu.Application") Set objImpRep = objImpApp.ActiveDocument strSelectedText = objImpRep.GetSelectedText objImpRep.CopyToClipboard If objImpRep.CopyToClipboard = 0 then MsgBox strSelectedText & " was copied to the clipboard." End If Set objImpRep = Nothing Set objImpApp = Nothing End Sub

172 Automate Impromptu Using Macros

Chapter 8: Methods

InsertQualificationLevel Method
Syntax

Database.InsertQualificationLevel(NewLevelName,[LevelType])
Applies To

Database
Description

Inserts a database qualification level to an existing Database object.


Discussion

SchemaLevel objects are added first. If the Database object already has SchemaLevel objects then CatalogLevel objects are added. If the Database already has a CatalogLevel object, inserting a CatalogLevel object will change the existing CatalogLevel object to a SchemaLevel object. The SchemaLevel object and the Table objects will be moved beneath the CatalogLevel object in the hierarchy. Note: This method will fail if the Database object already has two qualification levels, or if the Database has no Tables.
Parameters Description

NewLevelName

Required. Specifies the name of the qualification level object being added. Type: String

LevelType

Optional. Specifies the type of level being inserted: catalog or schema. Type: Integer The values are: 0 for a catalog level 1 for a schema level If the LevelType parameter is omitted, the following will be added: a schema level will be added to the database with no qualification. a catalog will be added if the database already has one level of qualification.

Automate Impromptu Using Macros 173

Chapter 8: Methods
Return Type

Nothing
Example

The following example creates a new catalog, sets the Database object, inserts two qualification levels, adds a second CatalogLevel object, adds two SchemaLevel objects to the second CatalogLevel object, adds a second SchemaLevel object to the first CatalogLevel object, and sets all the objects to nothing.
Option Explicit Sub Main() Dim DB As Object Dim ImpApp As Object Dim ImpCat As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.CreateCatalog "C:\Catalogs\Sample.cat", "OUTDOORS", 0 Set ImpCat = ImpApp.ActiveCatalog Set DB = ImpCat.Databases("OUTDOORS") DB.InsertQualificationLevel "Schema 1a", 1 DB.InsertQualificationLevel "Catalog 1", 0 DB.CatalogLevels.Add "Catalog 2" DB.CatalogLevels(2).SchemaLevels.Add "Schema 2a" DB.CatalogLevels(2).SchemaLevels.Add "Schema 2b" DB.CatalogLevels(1).SchemaLevels.Add "Schema 1b" Set DB = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

MoveTo Method
Syntax

FolderItem.MoveTo(DestinationFolder)
Applies To

FolderItem
Description

Moves the folder to the destination folder (the equivalent of a cut and paste).

174 Automate Impromptu Using Macros

Chapter 8: Methods
Discussion

Use the CopyTo method to keep a copy of the source-folder in its original location.
Parameters Description

DestinationFolder

Required. Specifies the destination to which the specified FolderItem object will be moved. Type: Object

Return Type

Nothing
Example

This macro moves folders and columns, adds new folders, renames folders and columns. The first three lines of the macro declare variables for three objects. The application object is created and assigned to the ImpApp variable. Next, a catalog is opened and made the active catalog. The folders of the active catalog are assigned to the CatFolders object. In the following two statements, folders are moved one folder to another. Next, new folders are added to the Order folder. Order is renamed Orders, and two of its subfolders are given more explicit names. The catalog is then closed and automatically saved.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim CatFolders As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\Catalogs\GO Sample.cat", "Creator" Set ImpCat = ImpApp.ActiveCatalog Set CatFolders = ImpCat.Folders CatFolders("Ordrdetl").MoveTo CatFolders("Order") CatFolders("Customer").Items("Customer").MoveTo _ CatFolders("Order") CatFolders("Order").Items.AddFolder "Additional Info." CatFolders("Order").Items.AddFolder "Conditions" CatFolders("Order").Name = "Orders" CatFolders("Orders").Items("Ordrdetl").Name = "Order Details" CatFolders("Orders").Items("Customer").Name = "Customer Name" ImpApp.CloseCatalog End Sub

Automate Impromptu Using Macros 175

Chapter 8: Methods

OpenCatalog Method
Syntax

Application.OpenCatalog CatalogName ,[UserClassID] ,[UserClassPassword] ,[DatabaseID] ,[DatabasePassword] ,[ConnectToDatabase]


Applies To

Application
Description

Opens the specified catalog.


Discussion

Use the OpenCatalog method to open a specific Impromptu catalog. Only one catalog can be open at a time. If you attempt to open more than one, the open operation will fail. If you invoke an OLE automation script from the Scheduler, the OpenCatalog method automatically connects to the database. In addition, the Scheduler passes all security information required by both Impromptu and the database to Impromptu.
Parameters Description

CatalogName

Required. Specifies the name of the catalog to be opened. Include the full path and name (including the extension) for the catalog.

UserClassID UserClassPassword DatabaseID DatabasePassword ConnectToDatabase

Optional. Required only for shared and distributed catalogs with multiple user classes. Optional. Required only for shared and distributed catalogs with multiple user classes. Optional. Required only for databases with database user IDs. Optional. Required only for databases with database user IDs. Optional. Specifies a Boolean value that overrides the current Impromptu setting for automatic connection to the database. The default is 1 (connect to database).

176 Automate Impromptu Using Macros

Chapter 8: Methods
Example

This macro moves folders and columns, adds new folders, renames folders and columns. The first three lines declare object variables. The application object is created and assigned to ImpApp. A catalog is opened, then made the active catalog. The folders of the active catalog are assigned to the CatFolders object. In the next two statements, folders are moved to different folders. Two new folders are added to the Order folder. The name of the Order folder is changed to Orders, then two of its members' names are changed to be more easily understood. Finally, the catalog is closed and the changes automatically saved. Note: You must use a valid path and filename for the catalog to run this macro.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim CatFolders As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\Catalogs\GO Sample.cat", "Creator" Set ImpCat = ImpApp.ActiveCatalog Set CatFolders = ImpCat.Folders CatFolders("Ordrdetl").MoveTo CatFolders("Order") CatFolders("Customer").Items("Customer").MoveTo _ CatFolders("Order") CatFolders("Order").Items.AddFolder "Additional Info." CatFolders("Order").Items.AddFolder "Conditions" CatFolders("Order").Name "Orders" CatFolders("Orders").Items("Ordrdetl").Name "Order Details" CatFolders("Orders").Items("Customer").Name "Customer Name" ImpApp.CloseCatalog End Sub

Automate Impromptu Using Macros 177

Chapter 8: Methods

OpenReport Method
Syntax

Application.OpenReport(FileName ,["PromptValueA1[, PromptValueA2, ][|PromptValueB1[, PromptValueB2, ]]..."]))


Applies To

Application
Description

Opens an Impromptu report.


Discussion

Use the OpenReport method to open an existing Impromptu report. The OpenReport method returns an Impromptu Report Document object. Use the OpenReport method to assign a value to an object variable created for an Impromptu report. For reports that prompt for picklist and Type In prompts at runtime, use PromptValueX# to specify values. PromptValuesX# must be enclosed in quotation marks, specified in the correct order, and must be separated by a vertical slash character ( | ).
Parameters Description

FileName PromptValueX#

Required. Specifies the name of the Impromptu report file (IMR) to be opened. Optional. Specifies values for picklist and Type-In prompts.Values within prompts are separated by commas. Values between prompts are separated by a vertical bar.

178 Automate Impromptu Using Macros

Chapter 8: Methods
Example

You have a report with three prompts. You wish to pass the values 40200 and 40101 to the first prompt, the "Australia" value to the second and the values 1,2 and 3 to the third. The syntax is as follows:
Set ImpRep = _ ImpApp.OpenReport("c:\myreport.imr","40200,40101|Australia|1,2,3")

Don't add spaces between passed values. The following example starts Impromptu (or uses the current invocation of Impromptu) and opens a report named prompt1.imr. Since the report prompts for a high and low value for Product Number, the OpenReport method includes values for these prompts.
Sub main Dim impapp As object Dim imprep As Object 'create an Impromptu 4.0 application object Set impapp = CreateObject("Impromptu.Application") impapp.Visible 1 impapp.OpenCatalog _ "c:\cognos\samples\outdoors.cat","Creator",,,,1 set imprep = _ impapp.OpenReport("c:\cognos\samples\prompt1.imr","40100|42000") imprep.CloseReport impapp.Quit End Sub

Automate Impromptu Using Macros 179

Chapter 8: Methods

OpenDrillDownReport Method
Syntax

Application.OpenDrillDownReport(Report,Predicate)
Applies To

Application
Description

Opens an existing Impromptu report for access by another application or report.


Discussion

Drill-down refers to the capability of one report or application to open an existing Impromptu report in the background and to extract information from it via a query. Any application that can provide a drilldown ability can access an Impromptu report. The terms of the query are described and passed using "predicates". A predicate is a string that provides the case-sensitive column names (equivalent of the names on the Data tab of a report query) and values to use as data filters. The columns named in the predicate must exist in both the drilling and drilled-down reports for values to be returned. For example, if you wanted to restrict the data displayed in a report to a range of dates, you'd specify the date range as a predicate, like this:
Dim Report as String Dim SelString as String SelString = "[""LowestDate""=""1997-0331"",""HighestDate""=""1998-03-31""]" Dim Rep As object Rep=App.OpenDrillDownReport(Report, SelString)

The predicate is typically created and defined using a Dim statement and the object name used as the predicate, as with SelString above. Each portion of the predicate string takes the following form:
"[""columnName""=""value""]"

Here, "columnName" is a column existing in both the source application and the target report, and "value" is an applicable numeric, date (in YYYY-MM-DD format), or character value or values. The paired double quotes and square brackets are required. A series of values is indicated using this syntax:
"[""columnName""=""value"",""columnName""=""value""]"

A range of values is indicated using this syntax:


"[""columnName""=""value"",""value""]"

With ranges, the first value is less than the second; that is, the first value must be a lower numeric value, an earlier date value, or start with a character with a higher sort order for text values. 180 Automate Impromptu Using Macros

Chapter 8: Methods A predicate contains one or more column names and their values. The predicate is passed as a single string. The placement of square brackets creates AND and OR logic. For example, a single set of outside brackets indicates AND, like this:
"[""a""=""value"",""b""=""value"",""c""=""value""]"

While, a pair of square brackets means OR, like this means OR.
"[[""a""=""value"",""b""=""value"",""c""=""value""]]"

By nesting the square brackets, you can include both AND and OR, like this:
"[""a""=""value"",[""b""=""value"",[""c""=""value"",""d""=""value ""]]]"

Each left-facing square bracket ([) creates another nesting level and "toggles" between AND an OR. So, the above example translates to the Boolean equivalent of "a AND (b OR (c AND d))". The value supplied for a column must be consistent with the column's datatype. Instead of a value, you can use the keywords NB or NULL. NB means a zero-length string, and is valid only for character expressions. NULL is equivalent to the SQL predicate IS NULL.
Parameter Description

Report Predicate
Example

Required. A string giving the fully qualified name of the Impromptu report to open and drill down. Required A string naming or describing the predicates to pass.

This example opens a report and passes query information using constant declarations. The first constant sets the Impromptu report to open. The second provides the column names and values to use in the query. In this case, the value for Product can be either Star Lite or StarDome. The query returns all sales data for one of these products available though the All Country Sales report.
Sub Main() 'declare variables Dim objImpApp As Object Dim objImpRep As Object 'set constants Const strReport = "C:\Program Files\Cognos\Impromptu 5.0\" & _ "Imp.5.0 Samples\Reports\All Country Sales.imr" Const strPredicate = _ "[[""Product""=""Star Lite"",""Product""=""StarDome""]]" Set objImpApp = CreateObject("Impromptu.Application") Set objImpRep = _ objImpApp.OpenDrillDownReport (strReport, strPredicate) Set objImpRep = Nothing Set objImpApp = Nothing End Sub

Automate Impromptu Using Macros 181

Chapter 8: Methods

Print Method, PrintOut Method


Syntax

ReportDocument.Print [FromPage] ,[ToPage] ,[Copies] ReportDocument.PrintOut [FromPage] ,[ToPage] ,[Copies]


Applies To

Report Document
Description

Prints the active report.


Discussion

Use either the Print or PrintOut method to print an Impromptu report from within an OLE automation script. Use the Printout method to print an Impromptu report in another scripting language. The methods are equivalent and both automatically collate multiple copies.
Parameters Description

FromPage ToPage Copies


Example

Sets the starting page for the print operation. Sets the last page for the print operation. Sets the number of copies to print.

This example prints two copies of the active report from page 2 to 3.
Sub Main() Dim objImpApp As Object Dim objImpRep As Object Set objImpApp = CreateObject("Impromptu.Application") Set objImpRep = objImpApp.ActiveDocument objImpRep.Print 2,3,2 Set objImpRep = Nothing Set objImpApp = Nothing End Sub

Publish Method
Syntax

PublishHTML.Publish (Dir,Prefix)

182 Automate Impromptu Using Macros

Chapter 8: Methods
Applies To

PublishHTML
Description

Publishes the referenced report as HTML.


Discussion

If Publish is successful, a value of True is returned. If Publish fails, a value of False is returned.

Automate Impromptu Using Macros 183

Chapter 8: Methods
Parameters Description

Dir

The directory where the HTML files will be placed. Required. The prefix of the HTML files to be created. Required.

Prefix
Return Type

Boolean

QueryDialog Method
Syntax

ReportDocument.QueryDialog
Applies To

Report Document
Description

Displays the Data tabQuery dialog box and suspends the macro to await input to any tab in the Query dialog box. Will also return Boolean value for OK or Cancel.
Discussion

To change any part of the query manually, use the Query Dialog Automation Method to suspend the macro to await input in the Query dialog box. Choose OK or Cancel to continue with the rest of the macro. Selecting OK saves any changes made in the Query dialog box and applies them to subsequent actions. Selecting CANCEL abandons any changes. Once you choose OK or CANCEL Impromptu returns a Boolean value of TRUE (which is -1) for OK, or FALSE (which is 0) for Cancel. For example, to display the Query dialog box for the ImpRep Object, insert the following into the macro:
button = ImpRep.QueryDialog

Note: This method will display the Query dialog box even if Impromptu is not visible.
Return Type

Boolean
Example

This example displays the query dialog box in the middle of the macro execution to allow user interaction before the macro continues.
Sub Main()

184 Automate Impromptu Using Macros

Chapter 8: Methods
Dim objImpApp As Object Dim objImpRep As Object Dim Button As Integer Set objImpApp = CreateObject("Impromptu.Application") Set objImpRep = objImpApp.ActiveDocument objImpRep.QueryDialog Set objImpRep = Nothing Set objImpApp = Nothing End Sub

Quit Method
Syntax

Application.Quit
Applies To

Application
Description

Exits Impromptu.
Discussion

Use the Quit method to exit the Impromptu application. Important: Save any changes in open reports before using the Quit method, as no verification is performed prior to exiting Impromptu in an OLE automation script. Use the Modified property to determine if there are any outstanding changes to be saved, and then use the Save method to save them.
Return Type

Nothing
Example

This example saves the current report and exits Impromptu.


Sub Main() Dim objImpApp As Object Dim objImpRep As Object Set objImpApp = CreateObject("Impromptu.Application") Set objImpRep = objImpApp.ActiveDocument objImpRep.Save objImpApp.Quit Set objImpRep = Nothing Set objImpApp = Nothing End Sub

Automate Impromptu Using Macros 185

Chapter 8: Methods

ReExecute Method
Syntax

ReportDocument.ReExecute
Applies To

Report Document
Description

Re-executes the query for the current report.


Discussion

Use the ReExecute method to execute the query for a specified report. The difference between the ReExecute method and the RetrieveAll method is that ReExecute actually executes the query again whereas RetrieveAll simply brings back data based on the current database cursor. If there were changes to the database since the last query execution, RetrieveAll will not reflect these changes whereas ReExecute will.
Return Type

Nothing
Example

This example executes the query for the active report. This macro can be used to keep the report up to date, especially if the data from the database is changing frequently.
Sub Main() Dim objImpApp As Object Dim objImpRep As Object Set objImpApp = CreateObject("Impromptu.Application") Set objImpRep = objImpApp.ActiveDocument objImpRep.ReExecute Set objImpRep = Nothing Set objImpApp = Nothing End Sub

Remove Method
Syntax

Object.Remove(Index)
Applies To

DeniedTables DeniedColumns

186 Automate Impromptu Using Macros

Chapter 8: Methods DeniedSchemas DeniedCatalogs DeniedFolderItems DeniedSelectValues


Description

Removes the item from the reference collection.


Discussion

If you want to remove an item from an ownership collection, use the Delete method.
Parameters Description

Index

Required. Specifies the number or the name of the item to be removed from the collection. Type: Variant

Return Type

Nothing
Example

The following example removes the first Table object from the DeniedTables collection. Note that a catalog must be open. This macro will run only if denied tables exist.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim DenTableObj As Object Dim User As Object Set ImpApp = CreateObject("Impromptu.Application") Set ImpCat = ImpApp.ActiveCatalog Set User = ImpCat.ActiveUserClass.UserClasses(1) Set DenTableObj = User.DeniedTables(1) User.DeniedTables(1).Remove DenTableObj Set DenTableObj = Nothing Set User = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

Automate Impromptu Using Macros 187

Chapter 8: Methods

RemoveFilterFor Method
Syntax

UserClass.RemoveFilterFor(ObjectFiltered)
Applies To

UserClass
Description

Removes a filter for the input object.


Discussion

Use this method to remove the filter expression from the Column or Table object set by the CreateFilterFor method. These objects are thus removed from the FilteredTable and FilteredColumn collection. An error occurs when the parameter is not a Column or Table object.
Parameters Description

ObjectFiltered

Required. Specifies the Column or Table object with the filter. Type: Object

Return Type

Nothing
Example

The following example removes the filter for the specified column.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim db as object Dim User As Object Set ImpApp = CreateObject("Impromptu.Application") Set ImpCat = ImpApp.ActiveCatalog Set db = ImpCat.Databases("OUTDOORS") Set User = ImpCat.ActiveUserClass.UserClasses(1) User.RemoveFilterFor db.Tables("COUNTRY").Columns("COUNTRY") Set db = Nothing Set User = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

188 Automate Impromptu Using Macros

Chapter 8: Methods

RemoveQualificationLevel Method
Syntax

Database.RemoveQualificationLevel
Applies To

Database
Description

Removes the qualification level immediately below the Database object.


Discussion

All lower level objects will be moved under the database. For example, if the Database object contains two qualification levels and this method is used, the catalog qualification level is removed the Database object will have Tables qualified by Schemas. This method will fail if the Database object doesnt have any qualification levels. It will also fail if, by removing the qualification level, two items of the same name will be in the same collection. For example, if removing the schema qualification level places two tables with the same name in the Tables collection, the method will fail.
Return Type

Nothing
Example

The following example removes the qualification level directly below the Database. A qualification level must exist in the database.
Sub Main() Dim DB As Object Dim ImpApp As Object Dim ImpCat As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\temp\GOSample.cat", "Creator" Set ImpCat = ImpApp.ActiveCatalog Set DB = ImpCat.Databases("OUTDOORS") DB.RemoveQualificationLevel Set DB = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

Automate Impromptu Using Macros 189

Chapter 8: Methods

Reset Method
Syntax

PublishHTML.Reset
Applies To

PublishHTML
Description

Resets the PublishHTML object to the settings as they were last saved in the Options box (Publish As HTML dialog box).
Discussion

If youve never changed the settings, the defaults are: TOC = True FromPage = 1 ToPage = 65535 TOCInFrame = True TOCByPageNumber = False If the method is successful, a value of True is returned. If the method failed, a value of False is returned.
Return Type

Boolean

RetrieveAll Method
Syntax

ReportDocument.RetrieveAll
Applies To

Report Document
Description

Use the RetrieveAll method to retrieve all rows from the database for the active report. Retrieves all rows from the database for the active report.
Return Type

Nothing

190 Automate Impromptu Using Macros

Chapter 8: Methods
Example

This example retrieves all the rows from the database for the active report.
Sub Main() Dim objImpApp As Object Dim objImpRep As Object Set objImpApp = CreateObject("Impromptu.Application") Set objImpRep = objImpApp.ActiveDocument objImpRep.RetrieveAll Set objImpRep = Nothing Set objImpApp = Nothing End Sub

RetrieveRows Method
Syntax

ReportDocument.RetrieveRows Rows
Applies To

Report Document
Description

Retrieves a specific number of rows from the database for the active report.
Discussion

Use the RetrieveRows method to retrieve a specific number of rows from the database for the active report. For example, you can retrieve the first 200 rows from the database.
Parameters Description

Rows

Required. Specifies the number of rows Impromptu retrieves from the database.

Example

This example retrieves 200 rows from the database for the active report.
Sub Main() Dim objImpApp As Object Dim objImpRep As Object Set objImpApp = CreateObject("Impromptu.Application") Set objImpRep = objImpApp.ActiveDocument objImpRep.RetrieveRows 200 Set objImpRep = Nothing Set objImpApp = Nothing End Sub

Automate Impromptu Using Macros 191

Chapter 8: Methods

SaveAs Method
Syntax

ReportDocument.SaveAs ReportName ,[Description] ,[SaveAsSnapshot]


Applies To

Report Document
Description

Saves the active report with a different name than its current one.
Discussion

Use the SaveAs method to save an active report under a new file name or in a different location. For example, you can update the name of a report so that it contains the current date by using the Date$ function together with the SaveAs method, as in the following:
Fname$ = "TTLS" + Mid$(Date$,1,2) _ + Mid$(Date$,4,2) ImpRep.SaveAs FName$

Parameters

Description

ReportName Description

Required. Specifies the file name for the report. Optional. Specifies a string value that's used as the report description. Optional. Specifies a Boolean value that determines whether to save the report as a snapshot. Specify either 0 (don't save as snapshot) or 1 (save as snapshot) for SaveAsSnapshot. The default is 0.

SaveAsSnapshot

Example

This example saves the current report to a new location with a new name.
Sub Main() Dim objImpApp As Object Dim objImpRep As Object Dim strRepName As String Set objImpApp = CreateObject("Impromptu.Application") Set objImpRep = objImpApp.ActiveDocument

192 Automate Impromptu Using Macros

Chapter 8: Methods
strRepName = "NewName.imr" objImpRep.SaveAs "C:\Cognos\Reports\" & strRepName Set objImpRep = Nothing Set objImpApp = Nothing End Sub

Save Method
Syntax

ReportDocument.Save [SaveAsSnapshot]; and Catalog.Save


Applies To

Report Document Catalog


Description

For the Report Document object, saves the active report either as an Impromptu report or as a snapshot. For the Catalog object, saves the current catalog. The save method is only necessary when the macro does not close the catalog or quit the application.
Discussion

For the Report Document object, use the Save method to save a report in an OLE automation script. For the Catalog object, the catalog is saved using the name in its Filename property. An error results if the filename is invalid or if the save-location is inaccessible. Report Document object:
Parameters Description

SaveAsSnapshot

Optional. Specifies a Boolean value that saves the specified Report Document object as a snapshot. Specify either 0 (don't save as snapshot) or 1 (save as snapshot) for SaveAsSnapshot. The default is 0.

Example

This example saves the current report and exits Impromptu.


Sub Main()

Automate Impromptu Using Macros 193

Chapter 8: Methods
Dim objImpApp As Object Dim objImpRep As Object Set objImpApp = CreateObject("Impromptu.Application") Set objImpRep = objImpApp.ActiveDocument objImpRep.Save objImpApp.Quit Set objImpRep = Nothing Set objImpApp = Nothing End Sub

SetProcedure Method
Syntax

StoredProcedure.SetProcedure "ProcedureName([[Descriptor] IN] [,[Descriptor] IN]... [,[Descriptor] OUT] [,[Descriptor] OUT]...) [STATUS]"
Applies To

Stored Procedure
Description

Sets the name, placeholders for input and output parameters, and a placeholder for the return value for a database stored procedure. The quotation marks are required syntax.
Discussion

Use the SetProcedure method to set the name and parameters when executing a database-stored procedure. Before you attempt to run a database-stored procedure, you must know: the stored procedure name; the datatype, order, and number input and output parameters for the stored procedure; the maximum size of any variable length parameters (such as VARCHAR and CHAR strings) for the stored procedure. For Descriptor, specify one of CHAR[n], VARCHAR[n], or LONGVARCHAR[n], where n is the maximum size of the variable length parameter. Impromptu's stored procedure methods do not support other variable length types (such as VARBINARY[n]).

194 Automate Impromptu Using Macros

Chapter 8: Methods For stored procedures that don't use variable length input or output parameters, you can specify only the IN and OUT keywords to indicate that parameters will be passed when the procedure is executed. Later, when you use the Execute method to execute the stored procedure, replace each instance of IN and OUT with variables that you've defined in the CognosScript macro. Similarly, if the stored procedure returns a value and you want to obtain that value in Impromptu, you must include the STATUS keyword in the SetProcedure method. When you later use the Execute method to execute the stored procedure, assign its return value to a variable that also replaces the STATUS keyword. For example, the following statements create variables for use as input parameters and a return value for a stored procedure. The stored procedure, called sp_do_cust_sales, takes a customer number, a start date, and an end date as input parameters. It then creates a new table for the specified customer and returns the total sales for that customer within the specified time period. (The details of the stored procedure are not included here.)
. . . Dim Dim Dim Dim

CustNo As Integer StartDate As Long EndDate As Long TotalSales As Single

ImpSP.SetProcedure "sp_do_cust_sales(IN, IN, IN) STATUS" TotalSales = ImpSP.Execute CustNo, StartDate, _ EndDate, TotalSales . . .

Note: TotalSales is used both within the Execute method and as the variable for the return value. If you don't specify variable types for the input and output parameters of the STATUS value, they're created as variants.

Automate Impromptu Using Macros 195

Chapter 8: Methods
Parameters Description

ProcedureName

Required. Sets the name of the stored procedure as defined in the database. Optional. Specifies the datatype and size of the parameters. Required only for stored procedures with variable length input or output parameters. Enter one of the following: VARCHAR[n] LONGVARCHAR[n] CHAR[n] where n is the maximum size allowed for the variable length parameter. The square brackets ( [.] ) surrounding the maximum size indicator are required syntax.

Descriptor

IN, OUT

Optional. Provides one or more parameter placeholders for stored procedures that have input or output parameters. You can include a total of 15 input and output parameters in a SetProcedure declaration.

STATUS

Optional. Provides a value placeholder for stored procedures which return a value.

196 Automate Impromptu Using Macros

Chapter 8: Methods

TOCAddColumn Method
Syntax

PublishHTML.TOCAddColumn(Column)
Applies To

PublishHTML
Description

Adds the specified grouped column to the Report Navigator when a report is published as HTML.
Discussion

If TOCAddColumn is successful, a value of True is returned. If TOCAddColumn fails, a value of False is returned. If you add a nongrouped or non-associated column, an error occurs.
Parameters Description

Column

Required. Specifies the name of grouped column or association 0-based index of the column to add to the Report Navigator. Type: String, or Long The 0-based index is the index of all columns in the query, not just the grouped columns.

Return Type

Boolean

UpdateCatalog Method
Syntax

Application.UpdateCatalog
Applies To

Application
Description

Updates the open catalog.

Automate Impromptu Using Macros 197

Chapter 8: Methods
Discussion

Use the UpdateCatalog method to refresh the contents of an open distributed catalog based on changes in the source catalog. This method is valid only when the open catalog is a local copy of a distributed catalog.
Return Type

Nothing
Example

This example updates an open distributed catalog based on any changes made to the master catalog.
Sub Main() Dim objImpApp As Object Dim objImpCat As Object Set objImpApp = CreateObject("Impromptu.Application") Set objImpCat = objImpApp.ActiveCatalog objImpApp.UpdateCatalog Set objImpCat = Nothing Set objImpApp = Nothing End Sub

UseDatabase Method
Syntax

ReportDocument.UseDatabase
Applies To

Report Document
Description

Removes snapshots and causes the specified Report Document object to get data from the database.
Discussion

If the macro is currently using data that's stored in a snapshot and you want to access data from the database, use the UseDatabase method to return to database access.
Return Type

Nothing
Example

This example changes the active report from a snapshot to a report that now retrieves data from the database again. You have to apply this macro to a report that was saved as a snapshot.

198 Automate Impromptu Using Macros

Chapter 8: Methods
Sub Main() Dim objImpApp As Object Dim objImpRep As Object Set objImpApp = CreateObject("Impromptu.Application") Set objImpRep = objImpApp.ActiveDocument objImpRep.UseDatabase Set objImpRep = Nothing Set objImpApp = Nothing End Sub

Automate Impromptu Using Macros 199

Chapter 8: Methods

200 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties

Automate Impromptu Using Macros 201

Chapter 9: Impromptu Properties

ActiveCatalog Property
Syntax

Application.ActiveCatalog
Applies To

Application
Description

Returns the active catalog object.


Discussion

Use this property to get the active Catalog object. The active catalog is the same as the Catalog object, and can be manipulated the same way as the Catalog object. Only one catalog at a time can be open.
Type

Object
Access

Read
Example

This macro adds a folder to the Active Catalog. All other folders are copied to the added folder. The first four lines of the macro declare variables for three objects and an integer. The application object is created and assigned to the ImpApp variable. Next, a catalog is created and attached to the OUTDOORS database. This catalog is made the active catalog. The folders of the active catalog are assigned to the CatFolders object. A description is added to the active catalog. A folder called Admin is added to CatFolders.

202 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties The next statement copies the folders from CatFolders to the Admin folder. The integer variable that was declared is used in the counting statement. The Customer item from the Customer folder of the active catalog is copied to the Order folder of the same catalog. The catalog is then closed and automatically saved.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim CatFolders as Object Dim x As Integer Set ImpApp = CreateObject("Impromptu.Application") ImpApp.CreateCatalog "GO Sample.cat", "OUTDOORS" Set ImpCat = ImpApp.ActiveCatalog set CatFolders = ImpCat.Folders ImpCat.Description = "Great Outdoors Sales Data Sample" CatFolders.AddFolder "Admin." ' You could also have: ' ImpApp.ActiveCatalog.Folders.AddFolder "Admin" For x = 1 To 8 CatFolders(x).CopyTo CatFolders("Admin.") Next x CatFolders("Customer").Items("Customer").CopyTo CatFolders("Order") ImpCat.Close End Sub

Automate Impromptu Using Macros 203

Chapter 9: Impromptu Properties

ActiveDocument Property
Syntax

Application.ActiveDocument
Applies To

Application
Description

Returns the currently active Report Document object for the specified Application object.
Discussion

When you have several reports open in an automation script, use the ActiveDocument property to write a generic subroutine that can access the methods of the active report. In this way, you don't have to write separate subroutines to operate on the various reports in your script.
Type

Object
Access

Read
Example

This example returns the name of the active report in a message box. Note: A report must be active.
Sub Main() Dim objImpApp As Object Dim objImpRep As Object Dim strImpRep As String Set objImpApp = CreateObject("Impromptu.Application") Set objImpRep = objImpApp.ActiveDocument MsgBox objImpRep.Name Set objImpRep = Nothing Set objImpApp = Nothing End Sub

204 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties

ActiveUserClass Property
Syntax

Catalog.ActiveUserClass
Applies To

Catalog
Description

Returns the active user class.


Discussion

Only the "Creator" UserClass object can edit itself. Other user classes may be able to modify their subordinate classes. See UserClass Object for details.
Type

Object
Access

Read
Example

The following example creates a user-class profile. The application object is created and assigned to ImpApp. Assuming a catalog is already open, it is assigned to ImpCat. The User variable is assigned the ActiveUserClass and user-class properties are assigned.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim User As Object Set ImpApp = CreateObject("Impromptu.Application") Set ImpCat = ImpApp.ActiveCatalog Set User = ImpCat.ActiveUserClass User.PlainTextPassword = "creator" User.QueryProcessing = 3 'flexible processing User.MinimizeConnectTime = FALSE User.CrossProductPermission = 2 'Prevent Set User = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

Automate Impromptu Using Macros 205

Chapter 9: Impromptu Properties

AllSelectedFrames Property
Syntax

ReportDocument.AllSelectedFrames
Applies To

Report Document
Description

Returns a list of selected frame objects and their corresponding child objects on the active Report Document.
Discussion

AllSelectedFrames returns a list of pointers to each frame object selected on the Report Document. The list, also called the SelectedFrames collection, is arranged in the order in which the objects were selected. Each object in the list is followed by any child objects of the parent. Individual SelectedFrame objects within the collection can be referenced by adding an index value to the property:
report.AllSelectedFrames(2)

Or, you can use the Item property with an index value:
SelectedFrames.Item(2)

Use the Count property first to determine the number of objects in the collection.
Example

This macro returns the number of SelectedFrames in each of two SelectedFrames collections created, objList and objFullList. The AllSelectedFrames property returns the objFullList collection.
Sub Main() Dim objImpApp As Object Dim objImpRep As Object Dim objList As Object Dim objFullList As Object Dim intParentFrames As Integer Dim intChildFrames As Integer Set objImpApp = CreateObject("Impromptu.Application") Set objImpRep = objImpApp.ActiveDocument Set objList = objImpRep.SelectedFrames Set objFullList = objImpRep.AllSelectedFrames intParentFrames = objList.Count intChildFrames = objFullList.Count - objList.Count MsgBox "Parent Frames: " & intParentFrames MsgBox "Child Frames: " & intChildFrames Set objFullList = Nothing Set objList = Nothing Set objImpRep = Nothing Set objImpApp = Nothing End Sub

206 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties

Application Property
Syntax

Object.Application
Applies To

Application CatalogLevel Column Database Report Document SchemaLevelTable UserClass


Description

Returns the Impromptu Application object.


Discussion

Use the Application property to access the Application methods for the active report. For example, if the active report is an OLE object called ImpRep, you can change the printer for the active report by accessing the FileSetPrinter method for the Application object as follows:
ImpRep.Application.FileSetPrinter "PostScript Printer on LPT1"

By using the Application property, you don't have to know the precise name of the Application object that contains the report object.
Type

Dispatch
Access

Read

Automate Impromptu Using Macros 207

Chapter 9: Impromptu Properties


Example

The following macro displays the name of the application using the application property of the Impromptu application. An object and a string variable are declared. The application object is created and assigned to the ImpApp variable. If a catalog is open, it is closed. The application is made visible, its name is stored in App, and the value of App is displayed in a message box. The resources of ImpApp are then freed by assigning ImpApp a Null value.
Sub Main() Dim ImpApp As Object Dim App As String Set ImpApp = CreateObject("Impromptu.Application") If Not ImpApp.ActiveCatalog Is Nothing Then ImpApp.CloseCatalog End If ImpApp.Visible True App = ImpApp.Application.Name MsgBox App Set ImpApp = Nothing End Sub

208 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties

CanAddOrModifyFolders Property
Syntax

UserClass.CanAddOrModifyFolders
Applies To

UserClass
Description

Sets or returns whether the UserClass object can add or modify folders.
Discussion

Use this property to determine whether the UserClass object can add or modify folders in the catalog.
Type

Boolean
Access

Read/Write
Example

The following example sets the CanAddOrModifyFolders, CanAddOrModifyUserClasses, and CanDirectEnterSQL properties for the active catalog.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim User As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\temp\outtest1.cat" Set ImpCat = ImpApp.ActiveCatalog Set User = ImpCat.ActiveUserClass.UserClasses(1) User.CanAddOrModifyFolders = FALSE User.CanAddOrModifyUserClasses = FALSE User.CanDirectEnterSQL = TRUE Set User = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

Automate Impromptu Using Macros 209

Chapter 9: Impromptu Properties

CanAddOrModifyUserClasses Property
Syntax

UserClass.CanAddOrModifyUserClasses
Applies To

UserClass
Description

Sets or returns whether the UserClass object can add or modify user classes.
Discussion

Use this property to determine whether the UserClass object can add or modify user classes in the catalog. Note: The value of this property is inherited by all child UserClass objects following the same user class inheritance rules as in the user interface.
Type

Boolean
Access

Read/Write
Example

The following example sets the CanAddOrModifyFolders, CanAddOrModifyUserClasses, and CanDirectEnterSQL properties for the active catalog.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim User As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\temp\outtest1.cat" Set ImpCat = ImpApp.ActiveCatalog Set User = ImpCat.ActiveUserClass.UserClasses(1) User.CanAddOrModifyFolders = FALSE User.CanAddOrModifyUserClasses = FALSE User.CanDirectEnterSQL = TRUE Set User = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

210 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties

CanCreateNewReports Property
Syntax

UserClass.CanCreateNewReports
Applies To

UserClass
Description

Sets or returns whether the UserClass object can create new reports.
Discussion

Use this property to determine whether the UserClass object can create new reports from the catalog. Note: The value of this property is inherited by all child UserClass objects following the same user class inheritance rules as in the user interface.
Type

Boolean
Access

Read/Write
Example

The following example sets the CanCreateNewReports, OuterJoinPermission, NonIndexSortingPermission, and SelectDistinctPermission properties.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim User As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\temp\outtest1.cat" Set ImpCat = ImpApp.ActiveCatalog Set User = ImpCat.ActiveUserClass.UserClasses(1) User.CanCreateNewReports = FALSE 'OuterJoinPermission is set to Warn User.OuterJoinPermission = 1 'NonIndexSortingPermission is set to Allow User.NonIndexSortingPermission = 0 'SelectDistinctPermission is set to Prevent User.SelectDistinctPermission = 2 Set User = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

Automate Impromptu Using Macros 211

Chapter 9: Impromptu Properties

CanDirectEnterSQL Property
Syntax

UserClass.CanDirectEnterSQL
Applies To

UserClass
Description

Sets or returns whether the UserClass object can enter SQL queries.
Discussion

Use this property to determine whether the UserClass object can enter SQL queries directly in the report. Note: The value of this property is inherited by all child UserClass objects following the same user class inheritance rules as in the user interface.
Type

Boolean
Access

Read/Write
Example

The following example sets the CanAddOrModifyFolders, CanAddOrModifyUserClasses, and CanDirectEnterSQL properties for the active catalog.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim User As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\temp\outtest1.cat" Set ImpCat = ImpApp.ActiveCatalog Set User = ImpCat.ActiveUserClass.UserClasses(1) User.CanAddOrModifyFolders = FALSE User.CanAddOrModifyUserClasses = FALSE User.CanDirectEnterSQL = TRUE Set User = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

212 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties

CatalogLevels Property
Syntax

Database.CatalogLevels
Applies To

Database
Description

Returns an collection of CatalogLevel objects.


Discussion

If the Database object does not support catalog qualification, trying to access a specific CatalogLevel object will fail.
Type

Object
Access

Read
Example

The following example opens a catalog, sets the database to an object variable, displays the name of the CatalogLevel object, and sets all objects to nothing.
Sub Main() Dim DB As Object Dim ImpApp As Object Dim ImpCat As Object Dim CatLevel As Object Dim CatLevelName As String Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\Catalogs\Sample.cat", "creator" Set ImpCat = ImpApp.ActiveCatalog Set DB = ImpCat.Databases("OUTDOORS") Set CatLevel = DB.CatalogLevels(1) CatLevelName = CatLevel.Name MsgBox CatLevelName Set CatLevel = Nothing Set DB = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

Automate Impromptu Using Macros 213

Chapter 9: Impromptu Properties

Columns Property
Syntax

Table.Columns
Applies To

Table
Description

Returns a collection of Column objects owned by the Table object.


Discussion

The Column objects in the Columns collection can be indexed either by name or by number.
Type

Object
Access

Read
Example

The following example displays the name of the first column in the collection.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim DB As Object Dim ColumnName As String Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\Catalogs\Sample.cat" Set ImpCat = ImpApp.ActiveCatalog Set DB = ImpCat.Databases(1) ColumnName = DB.Tables("COUNTRY").Columns(1).Name msgbox ColumnName Set DB = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

214 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties

Condition Property
Syntax

TableLink.Condition
Applies To

TableLink
Description

Returns the Expression object representing the join.


Discussion

For more information about creating a Condition, see the Expression object.
Type

Object
Access

Read
Example

This macro creates a join in the active catalog. Five objects are declared. The application object is created, and the open catalog is made active. The first database in the databases collection is assigned to the variable db. A new link between Branch and CustSite is added. The condition (which is an expression) is defined and saved with the Commit method. Note: To run this macro, a catalog must already be open and you must use valid table names.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim DB As Object Dim NewLink As Object Dim NewLinkExpression As Object Set ImpApp = CreateObject("Impromptu.Application") Set ImpCat = ImpApp.ActiveCatalog Set db = ImpCat.Databases(1) Set NewLink = ImpCat.TableLinks.Add _ (db.Tables("BRANCH"), db.Tables("CUSTSITE")) Set NewLinkExpression = NewLink.Condition With NewLinkExpression .Append db.Tables("BRANCH").Columns("BRANCH_CD") .Append 24 '= .Append db.Tables("CUSTSITE").Columns("BRANCH_CD") .Commit End With End Sub

Automate Impromptu Using Macros 215

Chapter 9: Impromptu Properties

Count Property
Syntax

Collection.Count
Applies To

DeniedSelectValues DeniedFolderItems DeniedColumns DeniedCatalogs DatabaseDefinitions DatabaseConnections Databases CatalogLevels Columns DeniedSchemas
Description

DeniedTables FilteredColumns FilteredTables Folders Items SchemaLevels SelectedFrames TableLinks Tables UserClasses

Returns the number of objects in the collection.


Discussion

Use this property in a For...Next loop to count to the end of the collection.
Type

Integer
Access

Read

216 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties


Example

The following example returns the number of tables in the catalog.


Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim DB As Object Dim NumTables As Integer Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\temp\test.cat", "Creator" Set ImpCat = ImpApp.ActiveCatalog Set DB = ImpCat.Databases(1) NumTables = DB.Tables.Count MsgBox NumTables Set DB = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

Automate Impromptu Using Macros 217

Chapter 9: Impromptu Properties

CrossProductPermission Property
Syntax

UserClass.CrossProductPermission
Applies To

UserClass
Description

Sets or returns whether the UserClass object has cross-product permission.


Discussion

Use this property to determine whether this UserClass object can create cross-product reports, is warned when attempting to them, or is prevented from them. Use the following values for this property: 0 = Allow 1 = Warn 2 = Prevent Note: The value of this property is inherited by all child UserClass objects following the same user class inheritance rules as in the user interface.
Type

Integer
Access

Read/Write
Example

The following example sets the CrossProductPermission for the active catalog.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim User As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\temp\outtest1.cat" Set ImpCat = ImpApp.ActiveCatalog Set User = ImpCat.ActiveUserClass.UserClasses(1) 'CrossProductPermission is set to Prevent User.CrossProductPermission = 2 Set User = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

218 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties

DatabaseConnections Property
Syntax

UserClass.DatabaseConnections
Applies To

UserClass
Description

Returns a collection of DatabaseConnection objects for the UserClass object.


Discussion

The items in this collection can only be referenced by name. Note: In this release of Impromptu OLE Automation, there can only be one DatabaseConnection object in the DatabaseConnections collection.
Type

Object
Access

Read
Example

This macro returns the user name for the first DatabaseConnection object in the Collection. Three object variables are declared, as well as one string variable. The application object is created and assigned to the ImpApp variable. A catalog is opened, made the active catalog and assigned to the ImpCat variable. The active user class is assigned to the User variable, and the user name for the first object in the DatabasesConnections collection is assigned to the username variable. The user name is shown in a message box. Before ending, the macro releases the resources allocated to the objects.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim User As Object Dim username As String Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog _ "c:\Imp_cat\bi admin.cat","Creator",,"biadmin","biadmin" Set ImpCat = ImpApp.ActiveCatalog Set User = ImpCatActiveUserClass username = User.DatabaseConnections(1).UserName msgbox username Set User = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

Automate Impromptu Using Macros 219

Chapter 9: Impromptu Properties

DatabaseDefinitions Property
Syntax

Application.DatabaseDefinitions
Applies To

Application
Description

An owning collection of defined databases.


Discussion

The items in this collection are indexed by logical name. They can be referenced by logical name or by index. If the index number or name you specify doesn't exist, the macro will not run.
Type

Object
Access

Read
Example

This macro displays the name of a database. The first four lines of the macro declare variables for three objects and a string. The application object is created and assigned to the ImpApp variable. Next, the DatabaseDefinitions property is assigned to the variable DB. The name of the first database in the DatabaseDefinitions collection is assigned by index to the variable DBName. The name is shown to the user. The objects are assigned nothing to release the allocated memory.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim DB As Object Dim DBName as String Set ImpApp = CreateObject("Impromptu.Application") Set DB = ImpApp.DatabaseDefinitions DBName = DB(1).Name MsgBox "The Name of the first Impromptu Database is " & DBName & "." Set DB = Nothing Set ImpApp = Nothing End Sub

220 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties

DatabaseItem Property
Syntax

SelectedFrame.DatabaseItem
Applies To

SelectedFrame
Description

Returns a string giving the fully qualified database column name of a selected text frame in a SelectedFrames collection.
Discussion

DatabaseItem returns a string for text frames and an empty string for non-text frames. The string takes this form:
database[.catalog[.schema]].table.column

DatabaseItem returns nothing when referencing calculated items that involve more than one database column.
Type

String
Access

Read
Example

This macro returns a SelectedFrame object and displays the value of the DatabaseItem property, among others.
Sub Main() Dim objImpApp As Object Dim objImpRep As Object Dim objSelectedFrame As Object Set objImpApp = CreateObject("Impromptu.Application") Set objImpRep = objImpApp.ActiveDocument Set objSelectedFrame = objImpRep.SelectedFrames(1) With objSelectedFrame MsgBox .Name MsgBox .Formula MsgBox .DatabaseItem MsgBox .QueryItem End With Set objSelectedFrame = Nothing Set objImpRep = Nothing Set objImpApp = Nothing End Sub

Automate Impromptu Using Macros 221

Chapter 9: Impromptu Properties

Databases Property
Syntax

Catalog.Databases
Applies To

Catalog
Description

Returns a collection of Database objects.


Discussion

The items in the collection can be indexed by name or by number. Note: In this release of Impromptu OLE Automation, there can only be one Database object in the Databases collection.
Type

Object
Access

Read
Example

This macro displays the name of the first object in the collection. The first three lines declare objects and a string. The next line creates the application object. The open catalog (assumed) is made active. The name of the first database in the collection is assigned to the DBName variable. The name is displayed in a message box. Note: To run this macro a Catalog must already be open. If a folder with the same name already exists, a second Branch folder will be created.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim DBName As String Set ImpApp = CreateObject("Impromptu.Application") Set ImpCat = ImpApp.ActiveCatalog DBName = ImpCat.Databases(1).Name msgbox DBName End Sub

222 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties

DBObject Property
Syntax

DatabaseConnection.DBObject
Applies To

DatabaseConnection
Description

Returns the Database object associated with the connection.


Discussion

The DatabaseConnections collection is also a property of the UserClass object.


Type

Object
Access

Read
Example

This macro returns the DatabaseObject name associated with the DatabaseConnection object. Four object variables are declared. The application object is created and assigned to the ImpApp variable. A catalog is opened, made the active catalog, and assigned to the ImpCat variable. The active user class is assigned to the User variable. The first DatabaseConnection in the DatabaseConnections collection is assigned to the dbConnect variable. Its name is shown in a message box and the resources allocated to the object variables are released.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim dbConnect As Object Dim User As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog _ "c:\Imp_cat\bi admin.cat","Creator",,"biadmin","biadmin" Set ImpCat = ImpApp.ActiveCatalog Set User = ImpCat.ActiveUserClass Set dbConnect = User.DatabaseConnections(1) msgbox dbConnect.DBObject.Name Set dbConnect = Nothing Set User = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

Automate Impromptu Using Macros 223

Chapter 9: Impromptu Properties

Definition Property
Syntax

DatabaseDefinition.Definition
Applies To

DatabaseDefinition
Description

Sets or returns the database connection string from the Cognos.ini file.
Discussion

The string must be valid for the connection to succeed.


Type

String
Access

Read/Write
Example

This macro displays the name of a database. Three object variables are declared, as well as a string variable. The application object is created and assigned to the ImpApp variable. The variable DB is assigned the collection of database definitions for Impromptu. DBName is assigned the name of the first database in the collection. The name is displayed to the user. The resources for the objects are then released.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim DB As Object Dim DBDefinition as String Set ImpApp = CreateObject("Impromptu.Application") Set DB = ImpApp.DatabaseDefinitions DBDefinition = DB("OUTDOORS").Definition MsgBox DBDefinition Set DB = Nothing Set ImpApp = Nothing End Sub

224 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties

DeniedCatalogs Property
Syntax

UserClass.DeniedCatalogs
Applies To

UserClass
Description

Returns a collection of CatalogLevel objects to which the UserClass object is denied access.
Discussion

Use this property to determine the CatalogLevel objects in the DeniedCatalogs collection. Any CatalogLevel objects that are in the DeniedCatalogs collection for the parent UserClass object are not inherited by the DeniedCatalogs collection of the child UserClass object.
Type

Object
Access

Read
Example

The following example returns the name of the first CatalogLevels object from the DeniedCatalogs collection.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim db as Object Dim User As Object Set ImpApp = CreateObject("Impromptu.Application") Set ImpCat = ImpApp.ActiveCatalog Set db = ImpCat.Databases("OUTDOORS") Set User = ImpCat.ActiveUserClass.UserClasses(1) MsgBox "Denied Catalogs: " & User.DeniedCatalogs(1).Name Set db = Nothing Set User = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

Automate Impromptu Using Macros 225

Chapter 9: Impromptu Properties

DeniedColumns Property
Syntax

UserClass.DeniedColumns
Applies To

UserClass
Description

Returns a collection of Column objects to which the UserClass object is denied access.
Discussion

Use this property to determine the Column objects in the DeniedColumns collection. Any Column objects that are in the DeniedColumns collection for the parent UserClass object are not inherited by the DeniedColumns collection of the child UserClass object.
Type

Object
Access

Read
Example

The following example returns the name of a Column object in the DeniedColumns collection.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim User As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\temp\outtest1.cat" Set ImpCat = ImpApp.ActiveCatalog Set User = ImpCat.ActiveUserClass.UserClasses(1) MsgBox User.DeniedColumns(1).Name Set User = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

226 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties

DeniedFolderItems Property
Syntax

UserClass.DeniedFolderItems
Applies To

UserClass
Description

Returns a collection of FolderItem objects to which the UserClass object is denied access.
Discussion

Use this property to determine the FolderItem objects in the DeniedFolderItems collection. Any FolderItem objects that are in the DeniedFolderItems collection for the parent UserClass object are not inherited by the DeniedFolderItems collection of the child UserClass object.
Type

Object
Access

Read
Example

The following example returns the name of a FolderItem object in the DeniedFolderItems collection.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim User As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\temp\outtest1.cat" Set ImpCat = ImpApp.ActiveCatalog Set User = ImpCat.ActiveUserClass.UserClasses(1) MsgBox User.DeniedFolderItems(1).Name Set User = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

Automate Impromptu Using Macros 227

Chapter 9: Impromptu Properties

DeniedSchemas Property
Syntax

UserClass.DeniedSchemas
Applies To

UserClass
Description

Returns a collection of SchemaLevel objects to which the UserClass object is denied access.
Discussion

Use this property to determine the SchemaLevel objects in the DeniedSchemas collection. Any SchemaLevel objects that are in the DeniedSchemas collection for the parent UserClass object are not inherited by the DeniedSchemas collection of the child UserClass object.
Type

Object
Access

Read
Example

The following example returns the first SchemaLevel object in the DeniedSchemas collection.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim db as object Dim User As Object Set ImpApp = CreateObject("Impromptu.Application") Set ImpCat = ImpApp.ActiveCatalog Set db = ImpCat.Databases("OUTDOORS") Set User = ImpCat.ActiveUserClass.UserClasses(1) MsgBox "Denied Schemas: " & User.DeniedSchemas(1).Name Set db = Nothing Set User = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

228 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties

DeniedSelectValues Property
Syntax

UserClass.DeniedSelectValues
Applies To

UserClass
Description

Returns a collection of FolderItem objects for which this UserClass object is denied permission to perform a select values operation.
Discussion

Use this property to determine the FolderItem objects that are denied permission to use a select distinct statement on columns with many unique values Any SchemaLevel objects that are in the DeniedSchemas collection for the parent UserClass object are not inherited by the DeniedSchemas collection of the child UserClass object. Note: If the SelectDistinctPermission property is set to 2 (Prevent), all columns are denied the permission to perform a Select Distinct operation regardless of whether they are FolderItem objects in the DeniedSelectValues collection.
Type

Object
Access

Read
Example

The following example adds a Column object to the DeniedSelectValues collection and returns the name of the Column object.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim User As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\temp\great sample.cat" Set ImpCat = ImpApp.ActiveCatalog Set User = ImpCat.ActiveUserClass.UserClasses(1) User.DeniedSelectValues.Add ImpCat.Folders("Customers").Items("Cust No") MsgBox User.DeniedSelectValues(1).Name Set User = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

Automate Impromptu Using Macros 229

Chapter 9: Impromptu Properties

DeniedTables Property
Syntax

UserClass.DeniedTables
Applies To

UserClass
Description

Returns a collection of Table objects to which the UserClass object is denied access.
Discussion

Use this property to determine the Table objects in the DeniedTables collection. Any Table objects that are in the DeniedTables collection for the parent UserClass object are not inherited by the DeniedTables collection of the child UserClass object.
Type

Object
Access

Read
Example

The following example returns the name of a Table object in the DeniedTables collection.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim User As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\temp\outtest1.cat" Set ImpCat = ImpApp.ActiveCatalog Set User = ImpCat.ActiveUserClass.UserClasses(1) MsgBox User.DeniedTables(1).Name Set User = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

230 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties

Description Property
Syntax

Catalog.Description
Applies To

Catalog
Description

Sets or returns a text description of the Catalog.


Discussion

Access is Read-Only if the catalog is a distributed clone of a master.


Type

String
Access

Read/Write (master Catalog) or Read (distributed clone Catalog)


Example

This macro opens a Catalog, makes it non-distributed, and displays its filename and description. The first four lines of the macro declare variables for two objects and two strings. The application object is created and assigned to the ImpApp variable. Next, a catalog is opened and made the active catalog. The active catalog is made non-distributed. Its filename is stored in the fname variable and is displayed. Its description is stored in the desc variable and is displayed. The resources allocated to the objects are then released. Note: To run this macro, you must use a valid path and filename with OpenCatalog.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim fname As String Dim desc As String Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "c:\Catalogs\sample.cat", "Creator" Set ImpCat = ImpApp.ActiveCatalog ImpCat.IsDistributed = False fname = ImpCat.Filename MsgBox "The filename of the Catalog is " & fname desc = ImpCat.Description MsgBox "The Catalog Description is " & desc Set ImpCat = Nothing Set ImpApp = Nothing End Sub

Automate Impromptu Using Macros 231

Chapter 9: Impromptu Properties

EncryptedPassword Property
Syntax

DatabaseConnection.EncryptedPassword
Applies To

DatabaseConnection UserClass
Description

Sets or returns the password for the database.


Discussion

Note that this string can be read and written, unlike the PlainTextPassword property for the DatabaseConnection object, which can only be written.
Type

String
Access

Read/Write
Example

This macro returns an encrypted password for the user on the first DatabaseConnection object. Three object variables are declared. The application object is created and assigned to the ImpApp variable. A catalog is opened, made the active catalog, and assigned to the ImpCat variable. The active user class is assigned to the User variable. The name of the first DatabaseConnection in the DatabaseConnections collection is shown in a message box. Before ending, the macro releases the resources allocated to the object variables.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim User As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog _ "c:\Imp_cat\bi admin.cat","Creator",,"biadmin","biadmin" Set ImpCat = ImpApp.ActiveCatalog Set User = ImpCat.ActiveUserClass MsgBox User.DatabaseConnections(1).EncryptedPassword Set User = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

232 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties

ErrorDocument Property
Syntax

Application.ErrorDocument
Applies To

Application
Description

Returns which document has returned errors via the GetNextQueryError method when running multiple documents.
Type

Object
Access

Read

Automate Impromptu Using Macros 233

Chapter 9: Impromptu Properties

ExportMetaTags Property
Syntax

PublishHTML.ExportMetaTags
Applies To

PublishHTML
Description

Determines whether HTML meta tags will be added to the HTML report.
Discussion

When a report is published in HTML format, you can have HTML metadata tags added to the report header. When used without being assigned a value, the property returns its current setting. The default is False (0). The tags are added to each page generated, including any table of contents pages. The tags take this form:
<meta name = Data content = column name, catalog ID, data type, column name, catalog ID, data type >

The content tag will contain these fields for each data column in the report.
Type

Boolean
Access

Read/Write
Example

This macro opens a specific Impromptu report and publishes it in HTML format. Since ExportMetaTags is set to True, information regarding the contents of the report is added to the header area as a meta tag.
Sub Main() Dim objImpApp as Object Dim objImpRep as Object Dim objImpHTMLRep as Object Set objImpApp = CreateObject("Impromptu.Application") objImpApp.Visible 1 'make Impromptu visible Set objImpRep = objImpApp.OpenReport("C:\Program Files\Cognos\" & _ "Impromptu 5.0\Imp.5.0 Samples\Reports\PTH-Products.imr") ' creates the HTML Report object Set objImpHTMLRep = objImpRep.PublishHTML objImpHTMLRep.Reset objImpHTMLRep.ExportMetaTags = True objImpHTMLRep.Publish "C:\Temp", "country" objImpApp.Quit Set objImpHTMLRep = Nothing Set objImpRep = Nothing Set objImpApp = Nothing End Sub

234 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties

Filename Property
Syntax

Catalog.Filename
Applies To

Catalog
Description

Returns the name of the file for the catalog.


Discussion

The string must be a valid filename. For 16-bit macros, a valid filename must take the DOS 8.3 form.
Type

String
Access

Read
Example

This macro opens a Catalog, makes it non-distributed, and displays its filename and description. The first four lines of the macro declare variables for two objects and two strings. The application object is created and assigned to the ImpApp variable. Next, a catalog is opened and made the active catalog. The active catalog is made non-distributed. Its filename is stored in the fname variable and is displayed. Its description is stored in the desc variable and is displayed. The resources allocated to the objects are then released. Note: To run this macro, you must use a valid path and filename with OpenCatalog.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim fname As String Dim desc As String Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "c:\Catalogs\sample.cat", "Creator" Set ImpCat = ImpApp.ActiveCatalog ImpCat.IsDistributed = False fname = ImpCat.Filename MsgBox "The filename of the Catalog is " & fname desc = ImpCat.Description MsgBox "The Catalog Description is " & desc Set ImpCat = Nothing Set ImpApp = Nothing End Sub

Automate Impromptu Using Macros 235

Chapter 9: Impromptu Properties

FilteredColumns Property
Syntax

UserClass.FilteredColumns
Applies To

UserClass
Description

Returns a collection of Column objects for which the UserClass object has filters.
Discussion

Use this property to determine the Column objects in the FilteredColumns collection. Any Table objects that are in the FilteredColumns collection for the parent UserClass object are not inherited by the FilteredColumns collection of the child UserClass object.
Type

Object
Access

Read
Example

The following example displays the name of the first Column object in the FilterColumns collection in a message box.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim db as object Dim User As Object Set ImpApp = CreateObject("Impromptu.Application") Set ImpCat = ImpApp.ActiveCatalog Set db = ImpCat.Databases("OUTDOORS") Set User = ImpCat.ActiveUserClass.UserClasses(1) MsgBox User.FilteredColumns(1).Name Set db = Nothing Set User = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

236 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties

FilteredTables Property
Syntax

UserClass.FilteredTables
Applies To

UserClass
Description

Returns a collection of Table objects for which the UserClass object has filters.
Discussion

Use this property to determine the Table objects in the FilteredTables collection. Any Table objects that are in the FilteredTables collection for the parent UserClass object are not inherited by the FilteredTables collection of the child UserClass object.
Type

Object
Access

Read
Example

The following example returns the name of the first Table object in the FilteredTables Collection.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim db as object Dim User As Object Set ImpApp = CreateObject("Impromptu.Application") Set ImpCat = ImpApp.ActiveCatalog Set db = ImpCat.Databases("OUTDOORS") Set User = ImpCat.ActiveUserClass.UserClasses(1) MsgBox User.FilteredTables(1).Name Set db = Nothing Set User = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

Automate Impromptu Using Macros 237

Chapter 9: Impromptu Properties

Folders Property
Syntax

Catalog.Folders
Applies To

Catalog
Description

Returns the top-level Items collection in a catalog.


Discussion

The Catalog object itself is the parent for items in this collection.
Type

Object
Access

Read
Example

This macro displays the name of the first object in the Folders collection. The first four lines of the macro declare variables for three objects and a string. The application object is created and assigned to the ImpApp variable. Next, a catalog is opened and made the active catalog. The folders of the active catalog are assigned to the CatFolders object. The name of the first folder in the collection is assigned to foldername. The name is displayed in a message box. Note: For this macro, you must use your own folder and column names, as well as a valid catalog path.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim CatFolders As Object Dim foldername As String Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\Catalogs\GO Sample.cat", "Creator" Set ImpCat = ImpApp.ActiveCatalog Set CatFolders = ImpCat.Folders foldername = CatFolders(1).Name msgbox foldername Set CatFolders = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

238 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties

Formula Property
Syntax

Expression.Formula
Applies To

Expression
Description

Returns the string that represents the formula of an expression.


Discussion

Use to view the expression.


Type

String
Access

Read
Example

This macro shows the condition for the second join in the collection. Three objects are declared. The application object is created and assigned to the ImpApp variable. A catalog is opened, made active, and assigned to the ImpCat variable. The formula for the condition of the second join in the TableLinks collection is shown in a message box. Before ending, the macro releases all resources allocated to the object variables.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim User As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\temp\great sample.cat" Set ImpCat = ImpApp.ActiveCatalog MsgBox ImpCat.TableLinks(2).Condition.Formula Set User = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

Automate Impromptu Using Macros 239

Chapter 9: Impromptu Properties

FromPage Property
Syntax

PublishHTML.FromPage
Applies To

PublishHTML
Description

Sets or returns which page of the Impromptu report will be the first page of the HTML report.
Discussion

The default value is the current value in the Options box. If youve never changed the default value, it is 1.
Type

32-bit integer
Access

Read/Write

240 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties

FullName Property
Syntax

Object.FullName
Applies To

Application Report Document


Description

Returns a string containing the file name for the specified Impromptu application.
Discussion

Use the FullName method to assign the file name to a string variable for the specified Impromptu application object or Report Document. This allows you to determine the exact name and location of the Impromptu executable file and any reports currently open in the automation script. You can then use these string values within the script. For example, you could open a log file to track the progress of the automation script. Within the log file, you could write the name of each Impromptu report executed or printed within the automation script.
Type

String
Example

This example returns the complete filename, including path, of the active report. This filename is then displayed in a message box.
Sub Main() Dim objImpApp As Object Dim objImpRep As Object Set objImpApp = CreateObject("Impromptu.Application") Set objImpRep = objImpApp.ActiveDocument Msgbox objImpRep.FullName Set objImpRep = Nothing Set objImpApp = Nothing End Sub

Automate Impromptu Using Macros 241

Chapter 9: Impromptu Properties

HasTextBlobLimit Property
Syntax

UserClass.HasTextBlobLimit
Applies To

UserClass
Description

Sets or returns whether the UserClass object has a text-blob limit.


Discussion

If set to True, the UserClass object has a limit on the number of characters it can reference from a large text object in the database. If set to False, the UserClass is not limited by the number of characters in a text-blob. Use the MaxTextBlobCharacters property to set the limit. This property is automatically set to True when the MaxTextBlobCharacters property has been set. Note: The value of this property is inherited by all child UserClass objects following the same user class inheritance rules as in the user interface.
Type

Boolean
Access

Read/Write
Example

The following example sets the HasTextBlobLimit and MaxTextBlobCharacters property for the active catalog.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim User As Object Set ImpApp = CreateObject("Impromptu.Application")" ImpApp.OpenCatalog "C:\temp\outtest1.cat" Set ImpCat = ImpApp.ActiveCatalog Set User = ImpCat.ActiveUserClass.UserClasses(1) User.HasTextBlobLimit = True User.MaxTextBlobCharacters = 50 Set User = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

242 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties

Interactive Property
Syntax

Application.Interactive Flag
Applies To

Application
Description

Sets or returns whether the user can interrupt data retrieval in an active report.
Discussion

Use the Interactive property to determine the value of the current setting, and for macros or macro subsections that may produce long and costly queries or require all data to be retrieved without interruption. Setting the Interactive property to 0, "locks" the macro and disables the Interrupt button (displayed in the lower-left corner of the screen). Setting the Interactive property to 1, enables the Interrupt button and allows the user to interrupt data retrieval.
Parameters Description

Flag

Optional. Specifies whether users can interrupt the retrieval of data. Users can interrupt data retrieval using either the Interrupt button in the lower-left corner of the Impromptu window the Esc key Acceptable values for Flag are 0 - Disable interactive execution 1 - Enable interactive execution When Flag is set to 0, Impromptu displays a Macro Lock message, indicating that interruption of data retrieval is not possible. If no Flag value is specified, the Interactive method returns the current Interactive setting.

Automate Impromptu Using Macros 243

Chapter 9: Impromptu Properties


Example

This example disables interaction with Impromptu while the report is being opened and enables it after the report has opened.
Sub Main() Dim objImpRep As Object Dim objImpApp As Object Const ReportPath = "C:\cognos\annual product sales.imr" Set objImpApp = CreateObject("Impromptu.Application") objImpApp.Interactive 0 'disable interacive execution Set objImpRep = objImpApp.OpenReport(ReportPath) objImpApp.Interactive 1 'enable interactive execution Set objImpRep = Nothing Set objImpApp = Nothing End Sub

IsDistributed Property
Syntax

Catalog.IsDistributed
Applies To

Catalog
Description

Sets or returns whether a catalog is a distributed master.


Discussion

Use this property with a master catalog to specify whether it is of the distributed type.
Type

Boolean
Access

Read/Write

244 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties


Example

This macro opens a Catalog, makes it distributed, and displays its filename and description. The first four lines of the macro declare variables for two objects and two strings. The application object is created and assigned to the ImpApp variable. Next, a catalog is opened and made the active catalog. The active catalog is made non-distributed. Its filename is stored in the fname variable and is displayed. Its description is stored in the desc variable and is displayed. The resources allocated to the objects are then released. Note: To run this macro, you must use a valid path and filename with OpenCatalog.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim fname As String Dim desc As String Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "c:\Catalogs\sample.cat", "Creator" Set ImpCat = ImpApp.ActiveCatalog ImpCat.IsDistributed = True fname = ImpCat.Filename MsgBox "The filename of the Catalog is " & fname desc = ImpCat.Description MsgBox "The Catalog Description is " & desc Set ImpCat = Nothing Set ImpApp = Nothing End Sub

Automate Impromptu Using Macros 245

Chapter 9: Impromptu Properties

IsKey Property
Syntax

Column.IsKey
Applies To

Column
Description

Sets or returns whether the Column object is a key.


Discussion

If the IsKey property is True, then the Column object is a key. If False, the Column object is not a key.
Type

Boolean
Access

Read/Write
Example

The following example adds a new column "REGION" of type "Char" to the COUNTRY table and sets it as a key. Three object variables are declared. The application object is created and assigned to the ImpApp variable. A catalog is opened, made the active catalog, and assigned to the ImpCat variable. The first database in the Databases collection is assigned to the DB variable. The REGION column is added to the COUNTRY table. REGION is made key. Before ending, the macro releases the resources allocated to the object variables.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim DB As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\Catalogs\Sample.cat" Set ImpCat = ImpApp.ActiveCatalog Set DB = ImpCat.Databases(1) DB.Tables("COUNTRY").Columns.Add "REGION",1 DB.Tables("COUNTRY").Columns("REGION").IsKey = TRUE Set DB = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

246 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties

Item Property
Syntax

Collection.Item
Applies To

CatalogLevels Columns Databases DatabaseConnections DatabaseDefinitions DeniedCatalogs DeniedColumns DeniedFolderItems DeniedSchemas DeniedSelectValues
Description

DeniedTables FilteredColumns FilteredTables Folders Items SchemaLevels SelectedFrames Tables TableLinks UserClasses

Returns the specified object in the collection.

Automate Impromptu Using Macros 247

Chapter 9: Impromptu Properties


Discussion

If the index is a string, the item with that name is returned or Empty is returned if no such named item exists. (String indexing may not be supported by all collections in all cases. See the specific collection for details.) If the item is a number, the item at that position in the list is returned. The numeric index is 1 based. Out of range indices cause an out of range exception. Other index types may be acceptable see the specific collection for details.
Type

Object
Access

Read
Example

The following example returns the name of the first user class.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim UserClass As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\cognos\test.cat", "Creator" Set ImpCat = ImpApp.ActiveCatalog Set UserClass = ImpCat.ActiveUserClass MsgBox UserClass.UserClasses.Item(1).Name Set UserClass = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

248 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties

Items Property
Syntax

Collection.Item and FolderItem.Items


Applies To

FolderItem
Description

Returns an ownership collection of child FolderItem objects.


Discussion

This is empty for value items, because only folders can have children. The names of items in the Folder must be unique.
Type

Object
Access

Read
Example

This macro displays the name of the first item in the Customers folder. The first four lines of the macro declare variables for three objects and a string. The application object is created and assigned to the ImpApp variable. Next, a catalog is opened and made the active catalog. The folders of the active catalog are assigned to the CatFolders object. The name of the first item in the Customers folder is assigned to the ItemName variable. The name is displayed in a message box.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim CatFolders As Object Dim ItemName As String Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\Catalogs\GO Sample.cat", "Creator" Set ImpCat = ImpApp.ActiveCatalog Set CatFolders = ImpCat.Folders ItemName = CatFolders("Customers").Items(1).Name msgbox ItemName Set CatFolders = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

Automate Impromptu Using Macros 249

Chapter 9: Impromptu Properties

LeftTable Property
Syntax

TableLink.Leftable
Applies To

TableLink
Description

Sets or returns the "left" table in the single-step link.


Discussion

Use the LeftTable property with the RightTable Property to create a join.
Type

Object
Access

Read/Write
Example

This macro returns the name of the left table in the join. Three objects are declared, as well as one string variable. The application object is created, and a catalog is opened and made active. The name of the LeftTable in the second join in the TableLinks collection is assigned to ltable. This name is shown to the user in a message box. Before ending, the macro releases the resources allocated to the object variables.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim User As Object Dim ltable As String Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\temp\Great Sample.cat" Set ImpCat = ImpApp.ActiveCatalog ltable = ImpCat.TableLinks(2).LeftTable.Name MsgBox "The name of the right table is " & ltable Set User = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

250 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties

MasterCatalogFilename Property
Syntax

Catalog.MasterCatalogFilename
Applies To

Catalog
Description

Returns the filename for the master catalog.


Discussion

Use this property to get the path and name of a master catalog for a distributed catalog. Note: The string returned is Read-Only.
Type

String
Access

Read
Example

This macro displays the Master Catalog Filename for a Catalog that has been created from a Distributed Catalog. Two objects are declared, as well as a string. The application object is created and assigned to the ImpApp variable. Next, the open catalog is made the active catalog. The name of the master catalog is assigned to the variable master, and the name of the master catalog is displayed to the user. Finally, the objects are assigned Null values so their resources are freed. Note: This macro must be run for a catalog that has been created from a distributed catalog, and a catalog must already be open.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim master As String Set ImpApp = CreateObject("Impromptu.Application") Set ImpCat = ImpApp.ActiveCatalog master = ImpCat.MasterCatalogFilename MsgBox "The Master Catalog Filename for the Catalog is " & master Set ImpCat = Nothing Set ImpApp = Nothing End Sub

Automate Impromptu Using Macros 251

Chapter 9: Impromptu Properties

MasterTable Property
Syntax

Table.MasterTable
Applies To

Table
Description

Returns the original Table object of this Table object, if this Table object is an alias.
Discussion

If this property is empty, this table is not an alias but an original.


Type

Object
Access

Read
Example

The following example creates an alias table for the BRANCH Table object and then it returns the name of the Master Table for the alias Table object. Four object variables are declared. The application object is created and assigned to the ImpApp variable. A catalog is opened, made the active catalog and assigned to the ImpCat variable. The first database in the Databases collection is assigned to the DB variable. An alias is created for BRANCH. The originating table's name is assigned to Master, and the name is shown to the user in a message box. Before ending, the macro releases the resources allocated to the object variables.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim DB As Object Dim Master As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\cognos\fulld1.cat"} Set ImpCat = ImpApp.ActiveCatalog Set DB = ImpCat.Databases(1) DB.Tables("BRANCH").CreateAlias "BRANCH ALIAS" Set Master = DB.Tables("BRANCH ALIAS").MasterTable MsgBox Master.Name Set Master = Nothing Set DB = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

252 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties

MaxQueryExecutionTime Property
Syntax

UserClass.MaxQueryExecutionTime
Applies To

UserClass
Description

Sets or returns the time limit to run a query for the UserClass object.
Discussion

Use this property to set the maximum time allowed for running a query for this UserClass object. The time unit is minutes. Use the QueryExecutionTimeWarnAfter property to determine the time at which the UserClass object is warned. Note: The value for this property must be greater than the value for QueryExecutionTimeWarnAfter property.
Type

Long
Access

Read/Write

Automate Impromptu Using Macros 253

Chapter 9: Impromptu Properties


Example

The following example sets the MaxRowsRetrieved, RowsRetrievedWarnAfter, MaxTablesPerReport, TablesPerReportWarnAfter,MaxQueryExecutionTime, QueryExecutionTimeWarnAfter, QueryProcessing, MinimizeConnectTime, and MaxTextBlobCharacters properties.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim User As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\temp\outtest1.cat" Set ImpCat = ImpApp.ActiveCatalog Set User = ImpCat.ActiveUserClass.UserClasses(1) User.MaxRowsRetrieved = 100 User.RowsRetrievedWarnAfter = 70 User.MaxTablesPerReport = 10 User.TablesPerReportWarnAfter = 5 User.MaxQueryExecutionTime = 3 User.QueryExecutionTimeWarnAfter = 2 'query processing is set to database Only User.QueryProcessing = 1 User.MinimizeConnectTime = TRUE User.MaxTextBlobCharacters = 50 Set User = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

MaxRowsRetrieved Property
Syntax

UserClass.MaxRowsRetrieved
Applies To

UserClass
Description

Sets or returns the maximum number of rows the UserClass object can retrieve.
Discussion

Use this property to determine the maximum number of rows retrievable for a report by this UserClass object. Use the RowsRetrievedWarnAfter property to determine the row at which the UserClass object is warned. Note: The value for this property must be greater than the value for RowsRetrievedWarnAfter property.

254 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties


Type

Long
Access

Read/Write
Example

The following example sets the MaxRowsRetrieved, RowsRetrievedWarnAfter, MaxTablesPerReport, TablesPerReportWarnAfter,MaxQueryExecutionTime, QueryExecutionTimeWarnAfter, QueryProcessing, MinimizeConnectTime, and MaxTextBlobCharacters properties.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim User As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\temp\outtest1.cat" Set ImpCat = ImpApp.ActiveCatalog Set User = ImpCat.ActiveUserClass.UserClasses(1) User.MaxRowsRetrieved = 100 User.RowsRetrievedWarnAfter = 70 User.MaxTablesPerReport = 10 User.TablesPerReportWarnAfter = 5 User.MaxQueryExecutionTime = 3 User.QueryExecutionTimeWarnAfter = 2 'query processing is set to database Only User.QueryProcessing = 1 User.MinimizeConnectTime = TRUE User.MaxTextBlobCharacters = 50 Set User = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

Automate Impromptu Using Macros 255

Chapter 9: Impromptu Properties

MaxTablesPerReport Property
Syntax

UserClass.MaxTablesPerReport
Applies To

UserClass
Description

Sets or returns the maximum number of tables the UserClass object can retrieve.
Discussion

Use this property to determine the maximum number of tables the UserClass object can use per report. Use the TablesPerReportWarnAfter Property to warn the UserClass object before.
Notes

The value for this property must be greater than the value for TablesPerReportWarnAfter property. The value in this property is inherited by all child UserClass objects following the same user class inheritance rules as in the user interface.

Type

Integer
Access

Read/Write

256 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties


Example

The following example sets the MaxRowsRetrieved, RowsRetrievedWarnAfter, MaxTablesPerReport, TablesPerReportWarnAfter,MaxQueryExecutionTime, QueryExecutionTimeWarnAfter, QueryProcessing, MinimizeConnectTime, and MaxTextBlobCharacters properties.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim User As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\temp\outtest1.cat" Set ImpCat = ImpApp.ActiveCatalog Set User = ImpCat.ActiveUserClass.UserClasses(1) User.MaxRowsRetrieved = 100 User.RowsRetrievedWarnAfter = 70 User.MaxTablesPerReport = 10 User.TablesPerReportWarnAfter = 5 User.MaxQueryExecutionTime = 3 User.QueryExecutionTimeWarnAfter = 2 'query processing is set to database Only User.QueryProcessing = 1 User.MinimizeConnectTime = TRUE User.MaxTextBlobCharacters = 50 Set User = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

Automate Impromptu Using Macros 257

Chapter 9: Impromptu Properties

MaxTextBlobCharacters Property
Syntax

UserClass.MaxTextBlobCharacters
Applies To

UserClass
Description

Sets or returns the maximum number of text-blob characters for the UserClass object.
Discussion

When you set this property, the HasTextBlobLimit property is automatically set to True. Note: The value of this property is inherited by all child UserClass objects following the same user class inheritance rules as in the user interface.
Type

Integer
Access

Read/Write

258 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties


Example

The following example sets the MaxRowsRetrieved, RowsRetrievedWarnAfter, MaxTablesPerReport, TablesPerReportWarnAfter,MaxQueryExecutionTime, QueryExecutionTimeWarnAfter, QueryProcessing, MinimizeConnectTime, and MaxTextBlobCharacters properties.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim User As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\temp\outtest1.cat" Set ImpCat = ImpApp.ActiveCatalog Set User = ImpCat.ActiveUserClass.UserClasses(1) User.MaxRowsRetrieved = 100 User.RowsRetrievedWarnAfter = 70 User.MaxTablesPerReport = 10 User.TablesPerReportWarnAfter = 5 User.MaxQueryExecutionTime = 3 User.QueryExecutionTimeWarnAfter = 2 'query processing is set to database Only User.QueryProcessing = 1 User.MinimizeConnectTime = TRUE User.MaxTextBlobCharacters = 50 Set User = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

Automate Impromptu Using Macros 259

Chapter 9: Impromptu Properties

MinimizeConnectTime Property
Syntax

UserClass.MinimizeConnectTime
Applies To

UserClass
Description

Sets or returns whether the connect time to the database is minimized.


Discussion

When this property is set to True, the Application object creates a temporary cache for query results and disconnects from the Database object as soon as the report has been run. Connection to the Database object is re-established when another query is run. When set to False, the Catalog object remains attached to the Database object while the Catalog object is open. Note: The value of this property is inherited by all child UserClass objects following the same user class inheritance rules as in the user interface.
Type

Boolean
Access

Read/Write

260 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties


Example

The following example sets the MaxRowsRetrieved, RowsRetrievedWarnAfter, MaxTablesPerReport, TablesPerReportWarnAfter,MaxQueryExecutionTime, QueryExecutionTimeWarnAfter, QueryProcessing, MinimizeConnectTime, and MaxTextBlobCharacters properties.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim User As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\temp\outtest1.cat" Set ImpCat = ImpApp.ActiveCatalog Set User = ImpCat.ActiveUserClass.UserClasses(1) User.MaxRowsRetrieved = 100 User.RowsRetrievedWarnAfter = 70 User.MaxTablesPerReport = 10 User.TablesPerReportWarnAfter = 5 User.MaxQueryExecutionTime = 3 User.QueryExecutionTimeWarnAfter = 2 'query processing is set to database Only User.QueryProcessing = 1 User.MinimizeConnectTime = TRUE User.MaxTextBlobCharacters = 50 Set User = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

Automate Impromptu Using Macros 261

Chapter 9: Impromptu Properties

Modified Property
Syntax

ReportDocument.Modified
Applies To

Report Document
Description

Returns a Boolean value based on whether the active report has been modified since the last time it was saved.
Discussion

Use the Modified property to determine whether to save a report. If the report contains outstanding changes, or if it has never been saved, the Modified property returns the value -1 (TRUE). If the current report hasn't changed since the last time it was saved, the Modified property returns the value 0 (FALSE).
Type

Boolean
Access

Read
Example

This macro determines if the current report has been modified since the last time it was saved. If the report was modified, it will be saved.
Sub Main() Dim objImpApp As Object Dim objImpRep As Object Const Report_Modified = -1 Const Report_NotModified = 0 Set objImpApp = CreateObject("Impromptu.Application") Set objImpRep = objImpApp.ActiveDocument If objImpRep.Modified = Report_Modified Then objImpRep.Save ElseIf objImpRep.Modified = Report_NotModified Then 'no save is necessary End If Set objImpRep = Nothing Set objImpApp = Nothing End Sub

262 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties

Name Property
Syntax

Object.Name
Applies To

Application Report Document Database CatalogLevel SchemaLevel Table Column DatabaseDefinition FolderItem UserClass
Description

Returns the name of the object.


Discussion

Use the Name property to return the value of an Application object or a Report Document object. For an Application object, Name returns the OLE registration name for the Impromptu application as it's stored in the OLE registration database. For Impromptu version 4.0, this string is "Impromptu.Application". For a Report Document object, the Name property returns the file name of the specified Impromptu report. For a Database, CatalogLevel, SchemaLevel, Table, Column object is the name associated with the object.
Type

String
Access

Read (Application, Report Document), Read/Write (Database, CatalogLevel, SchemaLevel, Table, Column)

Automate Impromptu Using Macros 263

Chapter 9: Impromptu Properties


Example

The following example opens a catalog, sets the database, displays the name of the CatalogLevel object, and sets all objects to nothing.
Option Explicit Sub Main() Dim DB As Object Dim ImpApp As Object Dim ImpCat As Object Dim CatLevel As String Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\Catalogs\Sample.cat", "creator" Set ImpCat = ImpApp.ActiveCatalog Set DB = ImpCat.Databases("OUTDOORS") CatLevel = DB.CatalogLevels(1).Name MsgBox CatLevel Set DB = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

NonIndexSortingPermission Property
Syntax

UserClass.NonIndexSortingPermission
Applies To

UserClass
Description

Sets or returns whether the UserClass object can sort non-indexed columns.
Discussion

Use the following values for this property: 0 = Allow 1 = Warn 2 = Prevent When sorting on non-indexed columns, you can hinder the performance of the Application object. By preventing certain UserClass objects from sorting on non-indexed columns, you can keep the Application object running at peak performance. Note: The value of this property is inherited by all child UserClass objects following the same user class inheritance rules as in the user interface.

264 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties


Type

Integer
Access

Read/Write
Example

The following example sets the CanCreateNewReports, OuterJoinPermission, NonIndexSortingPermission, and SelectDistinctPermission properties.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim User As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\temp\outtest1.cat" Set ImpCat = ImpApp.ActiveCatalog Set User = ImpCat.ActiveUserClass.UserClasses(1) User.CanCreateNewReports = FALSE 'OuterJoinPermission is set to Warn User.OuterJoinPermission = 1 'NonIndexSortingPermission is set to Allow User.NonIndexSortingPermission = 0 'SelectDistinctPermission is set to Prevent User.SelectDistinctPermission = 2 Set User = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

Automate Impromptu Using Macros 265

Chapter 9: Impromptu Properties

OuterJoinPermission Property
Syntax

UserClass.OuterJoinPermission
Applies To

UserClass
Description

Sets or returns the outer join permission for the UserClass object.
Discussion

Use the following values for this property 0 = Allow 1 = Warn 2 = Prevent Outer joins can produce very large reports because on queries, all rows in one table even if there is not matching row in another table is retrieved. By preventing outer joins, you can eliminate unnecessarily large reports. Note: The value of this property is inherited by all child UserClass objects following the same user class inheritance rules as in the user interface.
Type

Integer
Access

Read/Write

266 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties


Example

The following example sets the CanCreateNewReports, OuterJoinPermission, NonIndexSortingPermission, and SelectDistinctPermission properties.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim User As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\temp\outtest1.cat" Set ImpCat = ImpApp.ActiveCatalog Set User = ImpCat.ActiveUserClass.UserClasses(1) User.CanCreateNewReports = FALSE 'OuterJoinPermission is set to Warn User.OuterJoinPermission = 1 'NonIndexSortingPermission is set to Allow User.NonIndexSortingPermission = 0 'SelectDistinctPermission is set to Prevent User.SelectDistinctPermission = 2 Set User = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

Parent Property
Syntax

Collection.Parent
Applies To Report Document Column DatabaseDefinition Table CatalogLevels DatabaseConnections DeniedColumns DeniedColumns DeniedTables Folders Description Catalog Database FolderItem TableLink Columns DatabaseDefinitions DeniedFolderItems DeniedFolderItems FilteredColumns Items CatalogLevel DatabaseConnection SchemaLevel UserClass Databases Denied Catalogs DeniedCatalogs DeniedSchema FilteredTables SchemaLevels

Returns the parent object for the specified object.

Automate Impromptu Using Macros 267

Chapter 9: Impromptu Properties


Discussion

Use the Parent property to create generic procedures and functions that operate on parent objects. If the current object is an Impromptu report, you can use the Parent property to perform operations on its Application object For example, to change the user class for an active report object called IMPRep without knowing the name of the Application object, use the following:
ImpRep.Parent.ChangeUserClass "Manager"

Type

Object
Access

Read
Example

This macro returns the name of the parent for the specified table. In this case, the name will be the Database. Two objects and a string are declared. The string variable is assigned a path and filename for a value. The application object is created and assigned to the ImpApp variable. The application is made visible and the catalog indicated by the string is opened. The catalog is made the active catalog. The name of the parent of the first table of the first database in the Databases collection is displayed in a message box. The resources allocated to the objects are then released.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim sCatLoc As String sCatLoc = "C:\Catalogs\Sample.cat" Set ImpApp = CreateObject("Impromptu.Application") ImpApp.Visible True ImpApp.OpenCatalog sCatLoc, "Creator" Set ImpCat = ImpApp.ActiveCatalog MsgBox ImpCat.Databases(1).Tables(1).Parent.Name Set ImpCat = Nothing Set ImpApp = Nothing End Sub

268 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties

Path Property
Syntax

ReportDocument.Path
Applies To

Report Document
Description

Returns the path, not including the file name, for the specified report.
Discussion

Use the Path property to determine the location of a report for use at some point within a macro. For example, use the Path property when you wish to save all the files created by a macro to the same location as the active report.
Type

String
Access

Read
Example

This example returns the path of the active report.


Sub Main() Dim objImpApp As Object Dim objImpRep As Object Set objImpApp = CreateObject("Impromptu.Application") Set objImpRep = objImpApp.ActiveDocument Msgbox "The path of the report is: " & objImpRep.Path Set objImpRep = Nothing Set objImpApp = Nothing End Sub

Automate Impromptu Using Macros 269

Chapter 9: Impromptu Properties

PlainTextPassword Property
Syntax

DatabaseConnection.PlainTextPassword
Applies To

DatabaseConnection UserClass
Description

Sets the unencrypted password for the database.


Discussion

The string cannot be read to prevent other UserClass objects from determining any password because it is not encrypted.
Type

String
Access

Write

270 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties


Example

This macro sets the PlaintTextPassword for a new user's DatabaseConnection. Four object variables are declared. The application object is created and assigned to the ImpApp variable. A catalog is opened, made the active catalog, and assigned to the ImpCat variable. The second user class in the UserClasses collection is made the active user class and assigned to the newUser variable. The first DatabaseConnection in the DatabaseConnections collection is assigned to the dbConnect variable. The PlainTextPassword for dbConnect is set to "plain." Before ending, the macro releases the resources allocated to the object variables.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim dbConnect As Object Dim newUser As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "c:\Imp_cat\bi admin.cat","Creator",,"biadmin","biadmin" Set ImpCat = ImpApp.ActiveCatalog Set newUser = ImpCat.ActiveUserClass.UserClasses(2) Set dbConnect = newUser.DatabaseConnections(1) dbConnect.PlainTextPassword = "plain" Set dbConnect = Nothing Set newUser = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

Automate Impromptu Using Macros 271

Chapter 9: Impromptu Properties

QueryExecutionTimeWarnAfter Property
Syntax

UserClass.QueryExecutionTimeWarnAfter
Applies To

UserClass
Description

Sets or returns the time for the query execution at which the UserClass is warned.
Discussion

The time set for this property is the time the query is allowed to run before the UserClass object is warned. Note: The value for this property must be less than the value for the MaxQueryExecutionTime property.
Type

Long
Access

Read/Write

272 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties


Example

The following example sets the MaxRowsRetrieved, RowsRetrievedWarnAfter, MaxTablesPerReport, TablesPerReportWarnAfter, MaxQueryExecutionTime, QueryExecutionTimeWarnAfter, QueryProcessing, MinimizeConnectTime, and MaxTextBlobCharacters properties.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim User As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\temp\outtest1.cat" Set ImpCat = ImpApp.ActiveCatalog Set User = ImpCat.ActiveUserClass.UserClasses(1) User.MaxRowsRetrieved = 100 User.RowsRetrievedWarnAfter = 70 User.MaxTablesPerReport = 10 User.TablesPerReportWarnAfter = 5 User.MaxQueryExecutionTime = 3 User.QueryExecutionTimeWarnAfter = 2 'query processing is set to database Only User.QueryProcessing = 1 User.MinimizeConnectTime = TRUE User.MaxTextBlobCharacters = 50 Set User = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

Automate Impromptu Using Macros 273

Chapter 9: Impromptu Properties

QueryItem Property
Syntax

SelectedFrame.QueryItem
Applies To

SelectedFrame
Description

Returns a report query column name.


Discussion

QueryItem returns a string giving the query column item that identifies a selected text frame in a SelectedFrames collection. QueryItem returns an empty string for non-text frames.
Type

String
Access

Read
Example

This macro returns a SelectedFrame object and displays the value of the QueryItem property, among others.
Sub Main() Dim objImpApp As Object Dim objImpRep As Object Dim objSelectedFrame As Object Set objImpApp = CreateObject("Impromptu.Application") Set objImpRep = objImpApp.ActiveDocument Set objSelectedFrame = objImpRep.SelectedFrames(1) With objSelectedFrame MsgBox .Name MsgBox .Formula MsgBox .DatabaseItem MsgBox .QueryItem End With Set objSelectedFrame = Nothing Set objImpRep = Nothing Set objImpApp = Nothing End Sub

274 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties

QueryProcessing Property
Syntax

UserClass.QueryProcessing
Applies To

UserClass
Description

Sets or returns the state of query processing for the UserClass object.
Discussion

Use the following values for this property: 0 = Unknown (this value cannot be specified when setting this property) 1 = Database Only 2 = Limited Local Processing 3 = Flexible Processing The database only option requires that the query be completely processed on the database server in one query submission. Note: The value of this property is inherited by all child UserClass objects following the same user class inheritance rules as in the user interface.
Type

Integer
Access

Read/Write

Automate Impromptu Using Macros 275

Chapter 9: Impromptu Properties


Example

The following example sets the MaxRowsRetrieved, RowsRetrievedWarnAfter, MaxTablesPerReport, TablesPerReportWarnAfter,MaxQueryExecutionTime, QueryExecutionTimeWarnAfter, QueryProcessing, MinimizeConnectTime, and MaxTextBlobCharacters properties.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim User As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\temp\outtest1.cat" Set ImpCat = ImpApp.ActiveCatalog Set User = ImpCat.ActiveUserClass.UserClasses(1) User.MaxRowsRetrieved = 100 User.RowsRetrievedWarnAfter = 70 User.MaxTablesPerReport = 10 User.TablesPerReportWarnAfter = 5 User.MaxQueryExecutionTime = 3 User.QueryExecutionTimeWarnAfter = 2 'query processing is set to database Only User.QueryProcessing = 1 User.MinimizeConnectTime = TRUE User.MaxTextBlobCharacters = 50 Set User = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

ReadIsolationLevel Property
Syntax

DatabaseConnection.ReadIsolationLevel
Applies To

DatabaseConnection
Description

Sets or returns the read-transaction isolation level to request when connecting to the database.

276 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties


Discussion

Valid values for this property are -2 = passive transaction 0 = no transactions 1 = isolation level 1 2 = isolation level 2 3 = isolation level 3 4 = isolation level 4 5 = isolation level 5 6 = isolation level 6
Type

Integer
Access

Read/Write
Example

This macro returns the numeric value of the ReadIsolationLevel for the user's first DatabaseConnection object. Four object variables are declared. The application object is created and assigned to the ImpApp variable. A catalog is opened, made the active catalog, and assigned to the ImpCat variable. The user class is made the active user class and assigned to the User variable. The first DatabaseConnection object in the DatabaseConnections collection is assigned to the dbConnect variable. The ReadIsolationLevel for dbConnect is shown in a message box. Before ending, the macro releases the resources allocated to the object variables.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim dbConnect As Object Dim User As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog _ "c:\Imp_cat\bi admin.cat","Creator",,"biadmin","biadmin" Set ImpCat = ImpApp.ActiveCatalog Set User = ImpCat.ActiveUserClass Set dbConnect = User.DatabaseConnections(1) MsgBox dbConnect.ReadIsolationLevel Set dbConnect = Nothing Set User = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

Automate Impromptu Using Macros 277

Chapter 9: Impromptu Properties

ResultType Property
Syntax

Expression.ResultType
Applies To

Expression
Description

Returns an integer value for the type of data resulting from the expression.
Discussion

Valid values for this property are: 1 = Boolean 2 = number 3 = string 4 = date 5 = time 6 = date and time 7 = interval 8 = text blob
Type

Integer
Access

Read

278 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties


Example

This macro returns the Sales Amount expression numeric result type. In this case, the number corresponds to the number data type. Four object variables are declared. The application object is created and assigned to the ImpApp variable. A catalog is opened, made active, and assigned to the ImpCat variable. The folders are assigned to the CatFolders object. The column "Sale Amount" is assigned to the CatColumn variable and its numeric result type is displayed in a message box. Before ending, the macro releases all resources allocated to the object variables. Note: You should use a valid folder and column name, as well as catalog path.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim CatColumn as Object Dim CatFolders as Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\temp\sample.cat", "Creator" Set ImpCat = ImpApp.ActiveCatalog Set CatFolders = ImpCat.Folders Set CatColumn = CatFolders("Orders").Items("Sale Amount") MsgBox "Numeric result type is: " & CatColumn.ResultType Set CatColumn = Nothing Set CatFolders = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

Automate Impromptu Using Macros 279

Chapter 9: Impromptu Properties

RightTable Property
Syntax

TableLink.RightTable
Applies To

TableLink
Description

Sets or returns the "right" table in the join.


Discussion

Use the RightTable property with the LeftTable Property to create a join.
Type

Object
Access

Read/Write
Example

This macro returns the name of the right table in the join. Three objects are declared, as well as one string variable. The application object is created, and a catalog is opened and made active. The name of the RightTable in the second join in the TableLinks collection is assigned to rtable. This name is shown to the user in a message box. Before ending, the macro releases the resources allocated to the object variables.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim User As Object Dim rtable As String Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\temp\Great Sample.cat" Set ImpCat = ImpApp.ActiveCatalog rtable = ImpCat.TableLinks(2).RightTable.Name MsgBox "The name of the right table is " & rtable Set User = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

280 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties

RowsRetrievedWarnAfter Property
Syntax

UserClass.RowsRetrievedWarnAfter
Applies To

UserClass
Description

Sets or returns the number of rows retrieved at which the UserClass object is warned.
Discussion

Use this property to control the number of rows that are retrieved for a report before the UserClass object is warned. Note: The value for this property must be less than the value for the MaxRowsRetrieved property.
Type

Long
Access

Read/Write

Automate Impromptu Using Macros 281

Chapter 9: Impromptu Properties


Example

The following example sets the MaxRowsRetrieved, RowsRetrievedWarnAfter, MaxTablesPerReport, TablesPerReportWarnAfter, MaxQueryExecutionTime, QueryExecutionTimeWarnAfter, QueryProcessing, MinimizeConnectTime, and MaxTextBlobCharacters properties.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim User As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\temp\outtest1.cat" Set ImpCat = ImpApp.ActiveCatalog Set User = ImpCat.ActiveUserClass.UserClasses(1) User.MaxRowsRetrieved = 100 User.RowsRetrievedWarnAfter = 70 User.MaxTablesPerReport = 10 User.TablesPerReportWarnAfter = 5 User.MaxQueryExecutionTime = 3 User.QueryExecutionTimeWarnAfter = 2 'query processing is set to database Only User.QueryProcessing = 1 User.MinimizeConnectTime = TRUE User.MaxTextBlobCharacters = 50 Set User = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

282 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties

SchemaLevels Property
Syntax

Object.SchemaLevels
Applies To

CatalogLevel Database
Description

Returns a collection of SchemaLevel objects.


Discussion

If the Database object has a CatalogLevel object but no SchemaLevel object, trying to access an individual schema will fail.
Type

Object
Access

Read
Example

The following example opens a catalog, assigns the Database object to a variable, and returns the name of the SchemaLevel object. Before ending, the macro releases the resources allocated to the objects.
Sub Main() Dim DB As Object Dim ImpApp As Object Dim ImpCat As Object Dim SchLevName As String Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\Catalogs\Sample.cat", "creator" Set ImpCat = ImpApp.ActiveCatalog Set DB = ImpCat.Databases("OUTDOORS") SchLevName = DB.CatalogLevels(1).SchemaLevels(1).Name MsgBox SchLevName Set DB = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

Automate Impromptu Using Macros 283

Chapter 9: Impromptu Properties

SelectDistinctPermission Property
Syntax

UserClass.SelectDistinctPermission
Applies To

UserClass
Description

Sets or returns whether the UserClass object can set the query to select distinct values in a database.
Discussion

Use the following values for this property: 0 = Allow 1 = Warn 2 = Prevent Displaying duplicate rows can slow processing. By setting this property to Allow, you can optimize your processing time, by eliminating duplicates.
Notes

If this property is set to 2 (Prevent), all columns are denied the permission to perform a Select Distinct operation regardless of whether they are FolderItem objects in the DeniedSelectValues collection. The value of this property is inherited by all child UserClass objects following the same user class inheritance rules as in the user interface.

Type

Integer
Access

Read/Write

284 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties


Example

The following example sets the CanCreateNewReports, OuterJoinPermission, NonIndexSortingPermission, and SelectDistinctPermission properties.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim User As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\temp\outtest1.cat" Set ImpCat = ImpApp.ActiveCatalog Set User = ImpCat.ActiveUserClass.UserClasses(1) User.CanCreateNewReports = FALSE 'OuterJoinPermission is set to Warn User.OuterJoinPermission = 1 'NonIndexSortingPermission is set to Allow User.NonIndexSortingPermission = 0 'SelectDistinctPermission is set to Prevent User.SelectDistinctPermission = 2 Set User = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

Automate Impromptu Using Macros 285

Chapter 9: Impromptu Properties

SelectedFrames Property
Syntax

ReportDocument.SelectedFrames
Applies To

Report Document
Description

Returns a list of the selected frame objects on the active Report Document.
Discussion

SelectedFrames returns a list of pointers to each frame object selected on the Report Document. The list, also called the SelectedFrames collection, is arranged in the order in which the objects were selected. Individual SelectedFrame objects within the collection can be referenced by adding an index value to the property:
report.SelectedFrames(2)

Or, you can use the Item property with an index value:
SelectedFrames.Item(2)

Use the Count property first to determine the number of objects in the collection.
Example

This macro returns the number of SelectedFrames in each of two SelectedFrames collections created, objList and objFullList. The SelectedFrames property returns the objList collection.
Sub Main() Dim objImpApp As Object Dim objImpRep As Object Dim objList As Object Dim objFullList As Object Dim intParentFrames As Integer Dim intChildFrames As Integer Set objImpApp = CreateObject("Impromptu.Application") Set objImpRep = objImpApp.ActiveDocument Set objList = objImpRep.SelectedFrames Set objFullList = objImpRep.AllSelectedFrames intParentFrames = objList.Count intChildFrames = objFullList.Count - objList.Count MsgBox "Parent Frames: " & intParentFrames MsgBox "Child Frames: " & intChildFrames Set objFullList = Nothing Set objList = Nothing Set objImpRep = Nothing Set objImpApp = Nothing End Sub

286 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties

SQL Property
Syntax

ReportDocument.SQL
Applies To

Report Document
Description

Returns the SQL string from the Profile tabQuery dialog box.
Discussion

Use the Report SQL Property to retrieve the SQL string from the Profile tabQuery dialog box. For example, to set the string variable IMP_SQL to be the SQL for the ImpRep Object, insert the following into your macro:
IMP_SQL = ImpRep.SQL

Type

String
Access

Read
Example

This example displays the SQL string, from the Profile tab - Query dialog box, for the current report.
Sub Main() Dim objImpApp As Object Dim objImpRep As Object Set objImpApp = CreateObject("Impromptu.Application") Set objImpRep = objImpApp.ActiveDocument Msgbox objImpRep.SQL Set objImpRep = Nothing Set objImpApp = Nothing End Sub

Automate Impromptu Using Macros 287

Chapter 9: Impromptu Properties

SuppressTOCDuplicates Property
Syntax

PublishHTML.SuppressTOCDuplicates
Applies To

PublishHTML
Description

Controls what information is added to the Report Navigator when a report is published as HTML.
Discussion

When a report is published in HTML format, you can create a Report Navigator to act as a table of contents. It contains a list of grouped data items. If the group contains both header and footer information, both can appear in the contents. Sometimes the header and footer contain identical information which means duplicates will appear in the Report Navigator. Set the TOCDuplicates property to True to prevent footer entries from being added to the Report Navigator. When used without being assigned a value, the property returns its current setting. The default is False (0). Note that if a grouped data item appears in a header and in a primary list frame, it's not duplicated in the Report Navigator regardless of the setting for TOCDuplicates. A Report Navigator is not created unless at least one of these properties is set to True: TOC, TOCInFrame, or TOCByPageNumber.
Type

Boolean
Access

Read/Write

288 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties


Example

This macro opens a specific Impromptu report and publishes it in HTML format. The TOC property is set to 1, indicating a Report Navigator will be created. Since TOCDuplicates is set to True, no duplicates will appear in the Report Navigator.
Sub Main() Dim objImpApp as Object Dim objImpRep as Object Dim objImpHTMLRep as Object Const ReportLocation = "C:\Program Files\Cognos\Impromptu 5.0\" & _ "Imp.5.0 Samples\Reports\PTH-Sales by Country.imr" Set objImpApp = CreateObject("Impromptu.Application") Set objImpRep = objImpApp.OpenReport(ReportLocation) ' creates the HTML Report object Set objImpHTMLRep = objImpRep.PublishHTML ' set publishing options objImpHTMLRep.Reset 'takes the report's last saved PTH options objImpHTMLRep.TOC = 1 objImpHTMLRep.TOCInFrame = 1 'navigator on same page in frame objImpHTMLRep.ClearTOCColumns objImpHTMLRep.TOCAddColumn "Country" objImpHTMLRep.SuppressTOCDuplicates = True 'determine a folder and prefix for the published files objImpHTMLRep.Publish "C:\Temp", "sales" 'release variables Set objImpHTMLRep = Nothing Set objImpRep = Nothing Set objImpApp = Nothing End Sub

Automate Impromptu Using Macros 289

Chapter 9: Impromptu Properties

TableLinks Property
Syntax

Catalog.TableLinks
Applies To

Catalog
Description

Returns a collection of TableLink objects.


Discussion

Use this property to define a single-step link between two table objects.
Type

Object
Access

Read
Example

This macro determines the type of the first table link in the active catalog in the open application. Note: To run this macro a catalog must be open and you must use valid table names.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim Link As Object Dim LinkType As String Set ImpApp = CreateObject("Impromptu.Application") Set ImpCat = ImpApp.ActiveCatalog Set Link = ImpCat.TableLinks(1) LinkType = Link.Type MsgBox "The type of the first link in the catalog is " & LinkType End Sub

290 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties

Tables Property
Syntax

Object.Tables
Applies To

CatalogLevel SchemaLevel Database


Description

Returns a collection of Table objects.


Discussion

If the Database object supports qualification levels, attempts to access a specific Table object will fail because the name of the Table object is ambiguous. Full qualification must be provided.
Type

Object
Access

Read
Example

In the following example, name of the first item in the Tables collection is displayed to the user. Three objects are declared, as well as one string variable. The application object is created, and a catalog is opened and made active. The OUTDOORS database is assigned to the DB variable. The name of the first table in the Tables collection is assigned to the TableName variable. The name is displayed in a message box. Before ending, the macro releases the resources allocated to the object variables.
Sub Main() Dim DB As Object Dim ImpApp As Object Dim ImpCat As Object Dim TableName As String Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\Catalogs\Sample.cat", "Creator" Set ImpCat = ImpApp.ActiveCatalog Set DB = ImpCat.Databases("OUTDOORS") TableName = DB.Tables(1).Name msgbox TableName Set DB = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

Automate Impromptu Using Macros 291

Chapter 9: Impromptu Properties

TablesPerReportWarnAfter Property
Syntax

UserClass.TablesPerReportWarnAfter
Applies To

UserClass
Description

Sets or returns the number of tables used per report at which the UserClass object is warned.
Discussion

Use this property to warn the UserClass object that it is reaching the table limit set with the MaxTablesPerReport property.
Notes

The value for this property must be less than the value of the MaxTablesPerReport property. The value of this property is inherited by all child UserClass objects following the same user class inheritance rules as in the user interface.

Type

Integer
Access

Read/Write

292 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties


Example

The following example sets the MaxRowsRetrieved, RowsRetrievedWarnAfter, MaxTablesPerReport, TablesPerReportWarnAfter, MaxQueryExecutionTime, QueryExecutionTimeWarnAfter, QueryProcessing, MinimizeConnectTime, and MaxTextBlobCharacters properties.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim User As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\temp\outtest1.cat" Set ImpCat = ImpApp.ActiveCatalog Set User = ImpCat.ActiveUserClass.UserClasses(1) User.MaxRowsRetrieved = 100 User.RowsRetrievedWarnAfter = 70 User.MaxTablesPerReport = 10 User.TablesPerReportWarnAfter = 5 User.MaxQueryExecutionTime = 3 User.QueryExecutionTimeWarnAfter = 2 'query processing is set to database Only User.QueryProcessing = 1 User.MinimizeConnectTime = TRUE User.MaxTextBlobCharacters = 50 Set User = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

Automate Impromptu Using Macros 293

Chapter 9: Impromptu Properties

Title Property
Syntax

ReportDocument.Title title
Applies To

Report Document
Description

Returns or sets the report description.


Discussion

Use the Title property to: change the report description; return the current value of the report description.
Type

String
Access

Read/Write
Parameters Description

Title

Optional. Specifies the description string for the specified Report Document object. If no title is specified, the Title property returns the description string for the active report.

Example

This example sets the name of the active report as the report's description and returns the new description in a message box.
Sub Main() Dim objImpApp As Object Dim objImpRep As Object Dim strImpRep As String Set objImpApp = CreateObject("Impromptu.Application") Set objImpRep = objImpApp.ActiveDocument ' retrieve the report name without the extension Set strImpRep = Left$(objImpRep.Name, Len(objImpRep.Name) - 4) ' put the retrieved name in report's description objImpRep.Title strImpRep Msgbox "The Report Description is: " & objImpRep.Title Set objImpRep = Nothing Set objImpApp = Nothing End Sub

294 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties

TOC Property
Syntax

PublishHTML.TOC
Applies To

PublishHTML
Description

Sets or returns whether the HTML report includes the Report Navigator.
Discussion

If set, the Report Navigator is created for the HTML report. If set to 0 (False), the HTML report does not contain the Report Navigator. If set to a value other than 0, the HTML report contains a Report Navigator. The default is the current setting in the Options box (Publish As HTML dialog box). If youve never changed the default, it is True.
Type

Boolean
Access

Read/Write

Automate Impromptu Using Macros 295

Chapter 9: Impromptu Properties

TOCByPageNumber Property
Syntax

PublishHTML.TOCByPageNumber
Applies To

PublishHTML
Description

Sets or returns whether the Report Navigator contains page numbers and activates the Report Navigator.
Discussion

If set to 0 (False), the Report Navigator is not included. If set to a value other than 0, the Report Navigator is included. TOCByPageNumber and TOCInFrame will set TOC to True. The default is False.
Type

Boolean
Access

Read/Write

296 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties

TOCInFrame Property
Syntax

PublishHTML.TOCInFrame
Applies To

PublishHTML
Description

Sets or returns whether the Report Navigator appears in a separate page or in a frame and activates the Report Navigator.
Discussion

If set to 0 (False), the Report Navigator appears in a separate page. If set to a value other than 0, the Report Navigator appears in a frame. The default is the current setting in the Options box (Publish As HTML dialog box).
Type

Boolean
Access

Read/Write

Automate Impromptu Using Macros 297

Chapter 9: Impromptu Properties

ToPage Property
Syntax

PublishHTML.ToPage
Applies To

PublishHTML
Description

Sets or returns which page of the Impromptu report will be the last page of the HTML report.
Discussion

The default value is the current value in the Options box. If youve never changed the default, it is 65535.
Type

32-bit Integer
Access

Read/Write

Type Property
Syntax

object.Type
Applies To

TableLink Column
Description

Sets or returns the data type of the Column object or the join type of the TableLink object.

298 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties


Discussion

Use the following values for the Column object: 1 = Char 2 = Var Char 3 = Long Var Char 4 = Small Int 5 = Integer 6 = Decimal 7 = Float 8 = Double 9 = Binary 10 = Var Binary 11 = Quad 12 = Date 13 = Time 14 = DateTime 15 = Interval 16 = Database Key 17 = Blob 18 = Text 19 = Blob Array Use the following values for the TableLink object: 0 = Inner Join 1 = Left Outer Join 2 = Right Outer Join 3 = Full Outer Join
Type

Integer
Access

Read/Write

Automate Impromptu Using Macros 299

Chapter 9: Impromptu Properties


Example

The following example adds a new column "REGION" of type "Char" to the COUNTRY table and sets it as a key. Three object variables are declared. The application object is created, and assigned to the ImpApp variable. A catalog is opened, made the active catalog and assigned to the ImpCat variable. The first database in the catalog is assigned to the DB object. The REGION column is added to the COUNTRY table, and is made the key. Before ending, the macro releases the resources allocated to the object variables.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim DB As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\Catalogs\Sample.cat" Set ImpCat = ImpApp.ActiveCatalog Set DB = ImpCat.Databases(1) DB.Tables("COUNTRY").Columns.Add "REGION",1 DB.Tables("COUNTRY").Columns("REGION").IsKey = TRUE Set DB = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

300 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties

UseQueryWarnings Property
Syntax

Application.UseQueryWarnings QueryWarnings
Applies To

Application
Description

Sets whether Impromptu ignores warnings when executing a query.


Discussion

The UseQueryWarnings property enables or disables Impromptu's treatment of query warnings as errors. Query warnings are generated with a numeric identifier in the range 300 to 499. To have your OLE automation scripts ignore warnings such as those issued by the report Governor when the number of tables for a user class is exceeded, set UseQueryWarnings to 0.

UseQueryWarnings Property
Syntax

Application.UseQueryWarnings QueryWarnings
Type

Boolean
Access

Write
Parameters Description

QueryWarnings

Required. Specifies a Boolean value that sets whether Impromptu ignores query warnings when executing a query. By default, QueryWarnings is set to 1.

Automate Impromptu Using Macros 301

Chapter 9: Impromptu Properties

UserClasses Property
Syntax

UserClass.UserClasses
Applies To

UserClass
Description

Returns a collection of UserClass objects based on this UserClass object.


Discussion

Only the UserClass object called "Creator" does not have this relation with its parent object.
Type

Object
Access

Read
Example

The following example returns the name of a UserClass object from the UserClasses collection under Creator.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim username As String Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\temp\outtest1.cat" Set ImpCat = ImpApp.ActiveCatalog username = ImpCat.ActiveUserClass.UserClasses(1).Name msgbox "The name of the user is " & username Set ImpCat = Nothing Set ImpApp = Nothing End Sub

302 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties

UserName Property
Syntax

DatabaseConnection.UserName
Applies To

DatabaseConnection
Description

Sets or returns the name used to log onto the database.


Discussion

Although each UserClass object does not require a password, a name is required to identify the class.
Type

String
Access

Read/Write
Example

This macro returns the username for the first DatabaseConnection object in the collection. Four object variables are declared. The application object is created and assigned to the ImpApp variable. A catalog is opened, made the active catalog, and assigned to the ImpCat variable. The user is made the active user class and assigned to the User variable. The first DatabaseConnection in the DatabaseConnections collection is assigned to the dbConnect variable. The UserName for dbConnect is shown to the user in a message box. Before ending, the macro releases the resources allocated to the object variables.
Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim dbConnectObj As Object Dim User As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog _ "c:\Imp_cat\bi admin.cat","Creator",,"biadmin","biadmin" Set ImpCat = ImpApp.ActiveCatalog Set User = ImpCat.ActiveUserClass Set dbConnectObj = User.DatabaseConnections(1) MsgBox dbConnectObj.UserName Set dbConnectObj = Nothing Set User = Nothing Set ImpCat = Nothing Set ImpApp = Nothing End Sub

Automate Impromptu Using Macros 303

Chapter 9: Impromptu Properties

Value Property
Syntax

FolderItem.Value
Applies To

FolderItem
Description

Returns the expression in the FolderItem object.


Discussion

This property is Empty for folder (non-value) items.


Type

Object
Access

Read
Example

This macro adds calculation and condition columns to a catalog. Five object variables are declared. The application object is created and assigned to the ImpApp variable. An existing catalog is opened, made the active catalog and assigned to the ImpCat variable. The folders for the catalog are assigned to the CatFolders variable. The Sale Amount calculation is added to OrdrDetl in the Order folder. The expression is created using a series of Append statements. The Closed Sale folder is added to the Conditions item in the Orders folder. The expression is created using a series of Append statements. Finally, the changes are committed and the catalog is saved. Note: To use this macro you must use valid folder and column names as well as a valid catalog path.

304 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties


Sub Main() Dim ImpApp As Object Dim ImpCat As Object Dim CatFolders as Object Dim NewColumnExpression As Object Dim NewColumn As Object Set ImpApp = CreateObject("Impromptu.Application") ImpApp.OpenCatalog "C:\Catalogs\GO Sample.cat", "Creator" Set ImpCat = ImpApp.ActiveCatalog set CatFolders = ImpCat.Folders 'add calculation column to Order folder Set NewColumn = _ CatFolders("Order").Items("Ordrdetl").Items.AddItem _ ("Sale Amount", 1) Set NewColumnExpression = NewColumn.Value With NewColumnExpression .Append 100 '( .Append 2, 1 'numeric constant 1 .Append 23 '.Append _ CatFolders("Order").Items("Ordrdetl").Items("Disc Prcnt").Value .Append 21 '/ .Append 2, 100 'numeric constant 100 .Append 101 ') .Append 20 '* .Append 100 '( .Append _ CatFolders("Order").Items("Ordrdetl").Items("Price").Value .Append 20 '* .Append _ CatFolders("Order").Items("Ordrdetl").Items("Qty").Value .Append 101 ') .Commit End With 'Add closed sale filter column to the subfolder Conditions Set NewColumn = _ CatFolders("Order").Items("Conditions").Items.AddItem _ ("Closed Sale", 2) Set NewColumnExpression = NewColumn.Value NewColumnExpression.Append _ CatFolders("Order").Items("Closed Dt").Value NewColumnExpression.Append 36 'is not missing NewColumnExpression.Commit ImpCat.Save End Sub

Automate Impromptu Using Macros 305

Chapter 9: Impromptu Properties

Visible Property
Syntax

object.Visible Flag
Applies To

Application ReportDocument
Description

Sets or returns whether the Impromptu Application or ReportDocument is visible when activated in an OLE automation script.
Discussion

By default, the visibility of the Impromptu report document is the same as the Impromptu application. That is, if you run the application invisibly, the report document will also run invisibly, and vice versa. Tip: It's a good idea to set the report document and the application to run visibly when you first create a macro. By displaying the report and the application, you can debug your macros more effectively. In addition, if errors occur when Impromptu is running invisibly and no Quit method has been specified, then Impromptu remains in memory and you'll be unable to load it again. If this happens, write a simple macro that creates an Impromptu application object and then use the Quit method for that object. This should clean the application.
Type

Boolean
Access

Read/Write
Parameters Description

Flag

Optional. Specifies a Boolean value that sets whether Impromptu is displayed when invoked within a macro. Acceptable values for Flag are 0 and -1. The default value is 0 (run Impromptu invisibly). If no flag value is specified, the Visible method returns the current visibility setting for the Application. The return value is either -1 (TRUE) or 0 (FALSE).

306 Automate Impromptu Using Macros

Chapter 9: Impromptu Properties


Example

This example creates an Impromptu Application object, opens a catalog and makes Impromptu visible.
Sub Main() Dim objImpApp As Object Const Catalog_Name = "C:\cognos\great outdoors sales data.cat" Const True = -1 Set objImpApp = CreateObject("Impromptu.Application") objImpApp.OpenCatalog Catalog_Name, "Creator" objImpApp.Visible True Set objImpApp = Nothing End Sub

Automate Impromptu Using Macros 307

Glossary

Automate Impromptu Using Macros 309

Glossary
Dataset

An Impromptu report that stores data values you can use when applying a filter. A dataset is dynamic, meaning that when you use a dataset in a filter, the report that stores that dataset is re-run.
HotFile

A separate local data table that can be added to your catalog or used in a report as if it were a regular database table. Once you create a HotFile, any report or catalog can use it. You can use a HotFile to link to any database. For example, you can use HotFiles to compare this months data with last months data.
Ownership Collection

A collection whose elements (objects) are dependent on the collection's parent. For example, the Column objects in the Columns collection are dependent on the parent Table object. If the Table object is deleted, the Column objects in the Columns collection are also deleted.
Reference Collection

A collection whose elements (objects) are not dependent on the collection's parent, they are only referenced from a collection that the objects are depended on. For example, the Table objects in the FilteredTables collection are not dependent on the parent UserClass object. If the UserClass object is deleted, the Table objects in the FilteredTables do not cease to exist because the collection that the Table objects depend on still exists. An object cannot only belong to a reference collection, athought it can belong to more than one reference collection. It must also belong to an ownership collection.
Source Catalog

A distributed catalog on the LAN that is maintained by the administrator. When users open a distributed catalog, Impromptu makes a copy of the catalog on the users PC. However, Impromptu maintains a link with the original source catalog so that if any changes are made to the original, each users copy is updated automatically. Also called a master catalog.
Stored Procedure

A procedure defined and stored in a host database (such as Oracle or Sybase) that performs actions on the database.

310 Automate Impromptu Using Macros

Index
A
accessing, 78, 204, 207 active documents, 204 Impromptu, 207 stored procedures, 78 Activate, 82 ActiveCatalog, 202 ActiveDocument, 204 ActiveUserClass, 205 ActiveUserClass Property Catalog Automation Properties, 205 Add, 83, 84, 87, 89, 91 AddFolder, 93 adding, 83, 84, 87, 89, 91, 93, 94, 97, 99 existing object, 83, 84, 87, 89, 91 folder, 93 item, 94, 97 object, 83, 84, 87, 89, 91 tables, 99 AddItem, 94, 97 AddTable, 99 alias creating, 120 AllSelectedFrames, 206 an object in a collection deleting, 130 Append, 101 Append Method Expression Automation Methods, 101 Application, 207 Application Object (Impromptu), 14 application objects, 14 creating, 14 applying templates, 103 ApplyTemplate, 103 ASCII reports, 136 exporting, 136 assigning, 241 full name, 241

C
CanAddOrModifyFolders, 209 CanAddOrModifyFolders Property Catalog Automation Properties, 209 CanAddOrModifyUserClasses, 210 CanAddOrModifyUserClasses Property Catalog Automation Properties, 210 CanCreateNewReports, 211 CanCreateNewReports Property Catalog Automation Properties, 211 CanDirectEnterSQL, 212 CanDirectEnterSQL Property Catalog Automation Properties, 212 Catalog, 78 catalog closing, 109 creating, 121 making active, 202 Catalog Automation Collections, 40, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 54, 55, 56, 58, 59, 60, 78 Columns Collection, 40 DatabaseConnections Collection, 42 DatabaseDefinitions Collection, 44 Databases Collection, 41 DeniedCatalogs Collection, 45 DeniedColumns Collection, 46 DeniedFolderItems Collection, 47 DeniedSchemas Collection, 48 DeniedSelectValues Collection, 49 DeniedTables Collection, 51 FilteredColumns Collection, 52 FilteredTables Collection, 53

Automate Impromptu Using Macros 311

Index
Folders Collection, 54 Items Collection, 55 SchemaLevels Collection, 56 TableLinks Collection, 59 Tables Collection, 58 UserClasses Collection, 60 Catalog Automation Objects, 18, 19, 22, 23, 26, 28, 29, 31, 35, 36 Catalog Object, 18 CatalogLevel Object, 19 Column Object, 22 Database Object, 23 DatabaseConnection Object, 26 DatabaseDefinition Object, 28 FolderItem Object, 29 SchemaLevel Object, 31 TableLink Object, 35 UserClass Object, 36 Catalog Automation Properties, 205, 209, 210, 211, 212, 213, 214, 215, 216, 218, 219, 222, 223, 225, 226, 227, 228, 229, 230, 231, 232, 235, 236, 237, 238, 242, 244, 246, 247, 249, 250, 251, 252, 253, 254, 256, 258, 260, 264, 266, 270, 272, 275, 276, 280, 281, 283, 284, 290, 291, 292, 298, 302, 303, 304 ActiveUserClass Property, 205 CanAddOrModifyFolders Property, 209 CanAddOrModifyUserClasses Property, 210 CanCreateNewReports Property, 211 CanDirectEnterSQL Property, 212 CatalogLevels Property, 213 Columns Property, 214 Condition Property, 215, 216 CrossProductPermission Property, 218 DatabaseConnections Property, 219 Databases Property, 222 DBObject Property, 223 DeniedCatalogs Property, 225 DeniedColumns Property, 226 DeniedFolderItems Property, 227 DeniedSchemas Property, 228 DeniedSelectValues Property, 229 DeniedTables Property, 230 Description Property, 231 EncryptedPassword Property, 232 Filename Property, 235 FilteredColumns Property, 236 FilteredTables Property, 237 Folders Property, 238, 291 HasTextBlobLimit Property, 242 IsDistributed Property, 244 IsKey Property, 246 Item Property, 247 Items Property, 249 LeftTable Property, 250 MasterCatalogFilename Property, 251 MasterTable Property, 252 MaxQueryExecutionTime Property, 253 MaxRowsRetrieved Property, 254 MaxTablesPerReport Property, 256 MaxTextBlobCharacters Property, 258 MinimizeConnectTime Property, 260 NonIndexSortingPermission Property, 264 OuterJoinPermission Property, 266 PlainTextPassword Property, 270 QueryExecutionTimeWarnAfter Property, 272 QueryProcessing Property, 275 ReadIsolationLevel Property, 276 RightTable Property, 280 RowsRetrievedWarnAfter Property, 281 SchemaLevels Property, 283 SelectDistinctPermission Property, 284 TableLinks Property, 290 TablesPerReportWarnAfter Property, 292 Type Property, 298 UserClasses Property, 302 UserName Property, 303 Value Property, 304 Catalog Object Catalog Automation Objects, 18 CatalogLevel Object Catalog Automation Objects, 19 CatalogLevels, 213 CatalogLevels Collection Catalog Automation Collections, 78 CatalogLevels Property Catalog Automation Properties, 213 CatalogName, 104 CatalogOpened, 105 catalogs, 99, 176, 197 adding tables, 99 closing, 110 displaying names, 104 identifying open, 105 opening, 176 updating, 197 ChangeUserClass, 106 changing, 106 user classes, 106 Clear, 107 Clear Method Expression Automation Methods, 107 ClearTOCColumns, 108 clipboard copying, 119 Close, 109 CloseCatalog, 110

312 Automate Impromptu Using Macros

Index
CloseReport, 111 closing, 109, 110, 111 catalog, 109 catalogs, 110 reports, 111 Column Object Catalog Automation Objects, 22 Columns, 214 Columns Collection Catalog Automation Collections, 40 Columns Property Catalog Automation Properties, 214 Commit, 112 Commit Method Expression Automation Methods, 112 Condition, 215, 216 Condition Property Catalog Automation Properties, 215, 216 ConnectDatabase, 114 connected databases, 130 identifying, 130 connecting, 114 databases, 114 coping text, 119 copy special, 116 linking, 116 copying, 118, 119 clipboard, 119 folder, 118 special, 116 CopySpecialToClipboard, 116 CopyTo, 118 CopyToClipboard, 119 CreateAlias, 120 CreateCatalog, 121 CreateEmptyCatalog, 124 CreateFilterFor, 126 CreateSnapShot, 128 CreateStoredProcedure, 129 creating, 14, 120, 121, 124, 126 alias, 120 application objects , 14 catalog, 121 empty catalog, 124 filter, 126 snapshots, 128 stored procedures, 129 CrossProductPermission, 218 CrossProductPermission Property Catalog Automation Properties, 218

D
data, 243 interrupting retrieval, 243 data value, 152 database returning, 198 using, 198 database definitions, 220 identifying, 220 Database Object Catalog Automation Objects, 23 DatabaseConnected, 130 DatabaseConnection Object Catalog Automation Objects, 26 DatabaseConnections, 219 DatabaseConnections Collection Catalog Automation Collections, 42 DatabaseConnections Property Catalog Automation Properties, 219 DatabaseDefinition Object Catalog Automation Objects, 28 DatabaseDefinitions, 220 DatabaseDefinitions Collection Catalog Automation Collections, 44 DatabaseItem, 221 Databases, 41, 222 databases connecting, 114 disconnecting, 131 Databases Collection Catalog Automation Collections, 41 Databases Property Catalog Automation Properties, 222 database-stored procedures executing, 133 Dbase reports, 138 exporting, 138 DBObject, 223 DBObject Property Catalog Automation Properties, 223 Definition, 224 Delete, 130 deleting, 130 an object from a collection, 130 DeniedCatalogs, 225 DeniedCatalogs Collection Catalog Automation Collections, 45 DeniedCatalogs Property Catalog Automation Properties, 225 DeniedColumns, 226 DeniedColumns Collection Catalog Automation Collections, 46

Automate Impromptu Using Macros 313

Index
DeniedColumns Property Catalog Automation Properties, 226 DeniedFolderItems, 227 DeniedFolderItems Collection Catalog Automation Collections, 47 DeniedFolderItems Property Catalog Automation Properties, 227 DeniedSchemas, 228 DeniedSchemas Collection Catalog Automation Collections, 48 DeniedSchemas Property Catalog Automation Properties, 228 DeniedSelectValues, 229 DeniedSelectValues Collection Catalog Automation Collections, 49 DeniedSelectValues Property Catalog Automation Properties, 229 DeniedTables, 230 DeniedTables Collection Catalog Automation Collections, 51 DeniedTables Property Catalog Automation Properties, 230 Description, 231 Description Property Catalog Automation Properties, 231 DisconnectDatabase, 131 disconnecting, 131 databases, 131 displaying, 104 catalog names, 104 distributed catalog updating, 132 DistributedUpdate, 132 documents accessing active, 204 printing, 182 error 24584, 153 error 24585, 153 error 24587, 153 error 24588, 153 error 24589, 153 error 24590, 153 error 24591, 153 error 24592, 153 error 24593, 153 error documents, 233 identifying, 233 ErrorDocument, 233 errors, 153 Excel reports, 139 exporting, 139 Execute, 133 executing, 78, 133 database-stored procedures, 133 stored procedures, 78 existing object adding, 83, 84, 87, 89, 91 exiting, 185 Impromptu, 185 Export, 134 ExportASCII, 136 ExportData, 142 ExportDBase, 138 ExportExcel, 139 ExportHotFile, 140 exporting, 134 as ASCII reports, 136 as DBase reports, 138 as Excel reports, 139 as HotFiles, 140 as Lotus reports, 141 as SQL files, 143 as Text files, 144 as Transformer files, 145 PowerPlay data files, 142 reports, 134 ExportLotus, 141 ExportSQL, 143 ExportText, 144 ExportTransformer, 145 Expression Automation, 64 Token Table, 64 Expression Automation Methods, 101, 107, 112 Append Method, 101 Clear Method, 107 Commit Method, 112 Expression Automation Objects, 62 Expression Object, 62

E
empty catalog creating, 124 EncryptedPassword, 232 EncryptedPassword Property Catalog Automation Properties, 232 er, 153 error numbers, 153 error 24577, 153 error 24578, 153 error 24579, 153 error 24580, 153 error 24581, 153 error 24582, 153 error 24583, 153

314 Automate Impromptu Using Macros

Index
Expression Automation Properties, 239, 278 Formula Property, 239 ResultType Property, 278 Expression Object Expression Automation Objects, 62 GetFilterFor, 162 filtering, 162 GetNextQueryError, 163 GetParameter, 171 GetSelectedText, 172 getting, 152 data value, 152 error numbers, 153 next query error, 163 parameters, 171 selected text, 172

F
file names, 263 retrieving, 263 Filename, 235 Filename Property Catalog Automation Properties, 235 FileSetPrinter, 146 filter, 162 creating, 126 removing, 188 FilteredColumns, 236 FilteredColumns Collection Catalog Automation Collections, 52 FilteredColumns Property Catalog Automation Properties, 236 FilteredTables, 237 FilteredTables Collection Catalog Automation Collections, 53 FilteredTables Property Catalog Automation Properties, 237 filtering GetFilterFor, 162 folder adding, 93 copying, 118 moving, 174 FolderItem Object Catalog Automation Objects, 29 Folders, 238, 291 Folders Collection Catalog Automation Collections, 54 Folders Property Catalog Automation Properties, 238, 291 Formula, 239 Formula Property, 239 FromPage, 240 full name, 241 assigning, 241 FullName, 241

H
HasTextBlobLimit, 242 HasTextBlobLimit Property Catalog Automation Properties, 242 HotFiles, 140 exporting, 140 HTML, 240 Publish, 182, 197 publishing , 68

I
identifying, 130, 220, 233 connected databases, 130 database definitions, 220 error documents, 233 modified reports, 262 open catalogs, 105 Impromptu, 185, 207 accessing, 207 exiting, 185 quitting, 185 running macros, 6, 7 Impromptu OLE automation introduction, 10 inserting, 173 qualification level, 173 InsertQualificationLevel, 173 Interactive, 243 interrupting, 243 data retrieval, 243 introduction to Impromptu OLE automation, 10 IsDistributed, 244 IsDistributed Property Catalog Automation Properties, 244 IsKey, 246 IsKey Property Catalog Automation Properties, 246

G
GenerateReport, 148 GetAppVersionInfo, 150 GetDataValue, 152 GetErrorNumber, 153

Automate Impromptu Using Macros 315

Index
Item, 247 item adding, 94, 97 removing, 186 Item Property Catalog Automation Properties, 247 Items, 249 Items Collection Catalog Automation Collections, 55 Items Property Catalog Automation Properties, 249 modified reports, 262 identifying, 262 modifying, 294 report titles, 294 MoveTo, 174 moving, 174 folder, 174

N
Name, 263 next query error getting, 163 NonIndexSortingPermission, 264 NonIndexSortingPermission Property Catalog Automation Properties, 264

L
LeftTable, 250 LeftTable Property Catalog Automation Properties, 250 linking, 116 special copy, 116 Lotus reports, 141 exporting, 141

O
object adding, 83, 84, 87, 89, 91 OLE registration ID, 263 OpenCatalog, 176 OpenDrillDownReport, 180 opening, 70, 176 catalogs, 176 reports, 178 reports , 70 OpenReport, 178 OuterJoinPermission, 266 OuterJoinPermission Property Catalog Automation Properties, 266

M
macros at startup (Impromptu), 6 before opening a report (Impromptu), 7 running (Impromptu), 6, 7 using a command (Impromptu), 6 using a command line option (Impromptu), 7 using a PowerBar button (Impromptu), 6 MasterCatalogFilename, 251 MasterCatalogFilename Property Catalog Automation Properties, 251 MasterTable, 252 MasterTable Property Catalog Automation Properties, 252 MaxQueryExecutionTime, 253 MaxQueryExecutionTime Property Catalog Automation Properties, 253 MaxRowsRetrieved, 254 MaxRowsRetrieved Property Catalog Automation Properties, 254 MaxTablesPerReport, 256 MaxTablesPerReport Property Catalog Automation Properties, 256 MaxTextBlobCharacters, 258 MaxTextBlobCharacters Property Catalog Automation Properties, 258 MinimizeConnectTime, 260 MinimizeConnectTime Property Catalog Automation Properties, 260 Modified, 262

P
parameters, 171 stored procedures, 171 Parent, 267 parent retrieving, 267 Path, 269 path setting, 269 PlainTextPassword, 270 PlainTextPassword Property Catalog Automation Properties, 270 PowerPlay data files, 142 exporting, 142 Print, 182 printer files, 146 setting, 146 printing documents, 182

316 Automate Impromptu Using Macros

Index
PrintOut, 182 prompt methods, 94 Publish, 182 publish as HTML, 68 Publish HTML, 182, 197 PublishHTML Reset, 190 PublishHTML object, 108 PublishHTML Object (Impromptu), 68

R
ReadIsolationLevel, 276 ReadIsolationLevel Property Catalog Automation Properties, 276 ReExecute, 186 re-executing queries, 186 Remove, 186 RemoveFilterFor, 188 RemoveQualificationLevel, 189 removing, 186, 188, 189 filter, 188 item, 186 qualification level, 189 Report Document Object (Impromptu), 70 Report Navigator, 197 report titles, 294 modifying, 294 specifying, 294 reports closing, 111 exporting, 134 generating, 148 opening, 70, 178 Query Dialog Box, 184 saving, 193 saving as new name, 192 Reset, 190 PublishHTML, 190 ResultType, 278 ResultType Property Expression Automation Properties, 278 RetrieveAll, 190 RetrieveRows, 191 retrieving, 172, 190, 263 all rows, 190 file names, 263 OLE registration ID, 263 parent, 267 rows, 191 selected text, 172 SQL strings, 287 returning to database, 198 RightTable, 280 RightTable Property Catalog Automation Properties, 280 rows retrieving, 191 retrieving all, 190 RowsRetrievedWarnAfter, 281 RowsRetrievedWarnAfter Property Catalog Automation Properties, 281 running macros Impromptu, 6, 7

Q
qualification level inserting, 173 removing, 189 queries, 186 re-executing, 186 Query, 165 Query Dialog Box, 184 Query Error 101, 165 Query Error 102, 166 Query Error 103, 166 Query Error 104, 166 Query Error 105, 166 Query Error 106, 166 Query Error 107, 166 Query Error 108, 167 Query Error 109, 167 Query Error 110, 167 Query Error 111, 167 Query Error 112, 167 Query Error 113, 167 Query Error 300, 168 Query Error 301, 168 Query Error 302, 168 Query Error 303, 168 query warnings, 301 using, 301 QueryDialog, 184 QueryExecutionTimeWarnAfter, 272 QueryExecutionTimeWarnAfter Property Catalog Automation Properties, 272 QueryItem, 274 QueryProcessing, 275 QueryProcessing Property Catalog Automation Properties, 275 Quit, 185 quitting, 185 Impromptu, 185

Automate Impromptu Using Macros 317

Index

S
Save, 193 SaveAs, 192 saving, 192 as new name, 192 reports, 193 SchemaLevel Object Catalog Automation Objects, 31 SchemaLevels, 283 SchemaLevels Collection Catalog Automation Collections, 56 SchemaLevels Property Catalog Automation Properties, 283 SelectDistinctPermission, 284 SelectDistinctPermission Property Catalog Automation Properties, 284 selected text, 172 getting, 172 retrieving, 172 SelectedFrame , 73 SelectedFrames, 75, 286 SetProcedure, 194 setting, 146, 202, 269, 306 active catalog, 202 path, 269 printer files, 146 stored procedures, 194 visibility, 306 snapshots, 128 creating, 128 specifying report titles, 294 SQL, 287 SQL files, 143 exporting, 143 SQL strings, 287 Stored Procedure Object (Impromptu), 78 stored procedures, 78, 129, 171 accessing, 78 creating, 129 executing , 78 parameters, 171 setting, 194

T
Table, 33 table, 99 TableLink, 35 TableLink Object Catalog Automation Objects, 35 TableLinks, 290 TableLinks Collection Catalog Automation Collections, 59 TableLinks Property Catalog Automation Properties, 290 tables adding, 99 Tables Collection Catalog Automation Collections, 58 TablesPerReportWarnAfter, 292 TablesPerReportWarnAfter Property Catalog Automation Properties, 292 templates, 103 applying, 103 text copying, 119 Text files, 144 exporting, 144 Title, 294 TOC, 295 TOCAddColumn, 197 TOCByPageNumber, 296 TOCInFrame, 297 Token Table Expression Automation, 64 ToPage, 298 Transformer files, 145 exporting, 145 Type, 298 Type Property Catalog Automation Properties, 298

318 Automate Impromptu Using Macros

Index

U
UpdateCatalog, 197 updating, 132, 197 catalogs, 197 distributed catalog, 132 UseDatabase, 198 UseQueryWarnings, 301 user classes, 106 changing, 106 UserClass Object Catalog Automation Objects, 36 UserClasses, 302 UserClasses Collection Catalog Automation Collections, 60 UserClasses Property Catalog Automation Properties, 302 UserName, 303 UserName Property Catalog Automation Properties, 303 using, 301 database, 198 query warnings, 301

V
Value, 304 Value Property Catalog Automation Properties, 304 Visible, 306 visiblity, 306 setting, 306

W
windows, 82 activating, 82

Automate Impromptu Using Macros 319

You might also like