If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Applications & Tools > save with format using Cognos script editor

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-09-03, 15:41
dalex dalex is offline
Registered User
 
Join Date: Dec 2003
Location: Houston, TX
Posts: 1
save with format using Cognos script editor

Hello,

I am using Cognos script Editor to save an excel report with format. I am accomplishing this by using SendKeys. However, I find that sometimes the use of Sendkeys does not copy over any existing occurences of the excel file I'd like to copy over. So I read somewhere that a "Dir()" statement and a 'Kill' statement should be used to first detect and then delete any occurences of a selected excel file; at which the the cognos code (below) should then recreate it.

This is where I need asisstance. The below code does not seem to be functioning for me and I'm wondering if it's the order of the code or the code itself:

Any helpful tips to put an old project to rest would be much appreciated!

The objective of the code is to:

1) First kill any occurrences of pay.xls
2) Open Impromptu and save Pay.imr to Pay.xls (with format)
3) Open Pay.xls & open Load.xls (since pay.xls overwrites each time this is run, I use loadfile.xls to read from pay,xls and perform misc. vb functions).
4) Close everything

Dim CPApp as Object
Dim CPHot1 as Object
Dim CPRep as Object
DIM XLApp as Object
DIM objExcel as object

CPHot1 Kill ("P:\Standard\pay.xls")

Set CPApp = CreateObject ("CognosImpromptu.Application")
CPApp.Visible 1

CPApp.OpenCatalog "P:\Standard\Payable.cat"
CPApp.Visible True
Set CpHot1=CPApp.OpenReport("P:\Standard\Pay.imr")

SendKeys "%F",1
SendKeys "A",100
SendKeys "{TAB}",100
SendKeys "{DOWN 8}",100
SendKeys "{ENTER}",100
SendKeys "+{TAB}",100
SendKeys "P:\Standard\Pay.xls",100
SendKeys "{ENTER}",100
SendKeys "{TAB}",100
SendKeys "{ENTER}",100

CPHot1.CloseReport
CPAPP.closecatalog
CPApp.Quit
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = 1
objExcel.Application.Workbooks.Open ("P:\Standard\pay.xls")

objExcel.Application.Workbooks.Open ("P:\Standard\loadfile.xls")

Set CPRep = Nothing
Set CPApp = Nothing
Set CPHot1 = Nothing
Set XLApp = Nothing

End Sub
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On