AndyFreeman
IS-IT--Management
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
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