Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Impromptu Macro to save as Excel using a Loop

Status
Not open for further replies.

Rapunzel1

MIS
Jun 20, 2013
1
0
0
GB
[lipstick]Hi all,
This is my first post, so i am hoping someone can advise. I have a single Cognos Impromptu report with a type in prompt. I have a macro which uses a file list to dynamically populate the type in prompt and run the report multiple times based upon different prompt parameters. The macro then saves all the generated reports as .xls files in the same location. I'd like some advise on how i can get my macro to save different files to different locations, eg File1.xls saves to C:\File1, File2.xls saves to C:\File2 etc etc....

Thanks
 
Hello & welcome,
Since the Cognos Macro Script allows for loops, it's probably easiest to set an array for the different report prompts and locations, and then loop through the report, using the loop counter to change them appropriately.
Can you post your macro for suggestions?

Here is a simple example:
Code:
   For x = 1 to total
      Set objImpApp = CreateObject("CognosImpromptu.Application")
      objImpApp.OpenCatalog "E:\catalogues\MyCatalogue.cat","Creator",,,,1    
         strprompt = strdate+"|"+strlocation(x) 
         Set objImpRep = objImpapp.OpenReport("E:\Impromptu_Reports\Salesreport.imr",strprompt)
         strfile=strfileloc(x)+ "myreport.xls"          
         objImpRep.ExportExcelWithFormat strfile
         objImpRep.CloseReport
         Set objImpRep = Nothing
      objImpApp.Quit
      Set objImpApp = Nothing
   Next x
(I open and close Impromptu for each loop, as I have found that the Excel formatting can be unexpected if I re-run the report with changed prompts)

soi là, soi carré
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top