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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macro to Open and Publish to PDF Multiple Impromptu Reports

Status
Not open for further replies.

AndyFreeman

IS-IT--Management
Mar 22, 2004
70
GB
Here is my Macro as far as i have got it.
It is opening the report but then i get the following error message within cognos script.


INTRANET_IMP!Main(42)- R91"Object value is set to nothing"

Any help would be great

Cheers

Sub Main()


'Define variables
Dim directory, count
' for file location and counter
Dim x
' array variable
Dim strfilelocation as string ' location of account reports
Dim strfiledest as string ' location of files created
Dim strfilename(200) as string
Dim strfile as string
' filenames for reports and xl extracts

strfilelocation = "C:\imp test\"
'path to PP reports
strfiledest = "C:\imp test\"
'path for ppr reports
directory=Dir (strfilelocation & "*.imr")
'way to get file names of just PP reports

Do While directory<>""
count=count+1
Strfilename(count)=directory
Strfilename(count)=Left(strfilename(count),Len(strfilename(count))-4)
'remove .ppr from the end of the path
directory=Dir
Loop
Close #1 'close file

'PART II Open Reports & save an xl version
' of the same name to the specified location
'Loop for no. of reports
For x = 1 to count
Dim objImpApp as Object
Dim objImpRep as Object
Dim objPDFPub as Object
Set objImpApp = CreateObject("CognosImpromptu.Application")
objImpApp.Visible True
strfile = strfilelocation+strfilename(x) & ".imr"
objImpApp.OpenReport strfile
Set objPDFPub = objImpRep.PublishPDF
objImpRep.Publish strfiledest
objImpApp.Quit
Set objImpApp = Nothing
Set objImpRep = Nothing
Set objPDFPub = Nothing
Next x


End Sub
 
If it is easier to Publish to HTMl then i could use that as the solution
 
You're missing a line to set ObjImpRep
Instead of:
objImpApp.OpenReport strfile
try:
Set objImpRep = objImpApp.OpenReport(strfile)


soi la, soi carre
 
Ok thanks 4 that.
It is now not a cognos error that is stopping things from running.

The report now opens, then within Impromptu i get an error window pop up saying "c:\imp test\pdf has been locked by another user or program. YOu cannot use it at this time. "

Thing is tho that is a folder and have tried rebooting then running it.

What could be locking the folder?

Andy
 
I think you need to give the saved pdf a valid name; your variable "strdest" appears to be a path. Try changing
objImpRep.Publish strfiledest
to
objImpRep.Publish strfiledest + "AndysPDF"

soi la, soi carre
 
You should be publishing the PDF object, not the report.
Instead of:
Set objPDFPub = objImpRep.PublishPDF
objImpRep.Publish strfiledest

You need:
Set objPDFPub = objImpRep.PublishPDF
objPDFPub.Publish strfiledest & strfilename(x) & ".pdf"



Pain is stress leaving the body.

DoubleD [bigcheeks]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top