Run marco


Is someone got this situation ?

If i set the database directly in the by openning tab Catalog and selecting Tables and then select the database example DB1

Even i set my macro to use DB2 like below, the report still running on DB1 it seems that the database set in the catalog take over the macro ?

Set objImpApp = CreateObject(“CognosImpromptu.Application”)
objImpApp.Visible True
objImpApp.OpenCatalog cognos_drive & cognos_catalog, "Creator"
Set objImpCat = objImpApp.ActiveCatalog
Set objDB = objImpCat.Databases(DB2)

In what case Set objDB = objImpCat.Databases will take effect ?



it is a while ago since i wrote a Cognos script for impromptu… :wink:

i looked through my archives and found the code below. I thought it was used for creating or changing catalogs with a macro… ???

'force all variables to be declared
Option Explicit

'declare a function which determines the filename without the extension
Declare Sub GenerateTableFolder(intTableCounter As Integer)

'declare the variables
Dim objImpApp As Object
Dim objImpCat As Object
Dim objDatabase As Object
Dim objCatFolders As Object

Dim intFolderCounter As Integer
Dim intFolderCount As Integer
Dim intTableCounter As Integer
Dim intTableCount As Integer

Sub Main()
Set objImpApp = CreateObject(“Impromptu.Application”)
'there has to be an active catalog
If objImpApp.CatalogOpened = 0 Then
MsgBox “Please open a catalog first!”, 0, "No Catalog Opened"
Exit Sub
Set objImpCat = objImpApp.ActiveCatalog
Set objDatabase = objImpCat.Databases(1)
intTableCount = objDatabase.Tables.Count
If intTableCount = 0 Then
’If there are no tables in the catalog, there is no need
’to create a folder of the tables
MsgBox “No tables in the catalog!”, 0, "No tables"
Exit Sub
Set objCatFolders = objImpCat.Folders
’Make the folder “Original Tables”. If this folder already exists
’there will be an error. A check routine can be build but is
’omitted in this macro.
objCatFolders.AddFolder(“Original Tables”)
For intTableCounter = 1 To intTableCount
’For each available table there will be a folder created in
’the procedure "GenerateTableFolder"
Next intTableCounter
End If
End If

Thank you very much !