DotNetGnat
Programmer
Hi guys,
I have this following code...i have already included error handling and thanks to DoubleD who helped me with this. BUT
the code does not work in all cases...
for example:
case 1: if there is any error in the file path or if there is any error in the printer(if i am trying to print my report) the code traps the error and logs it and moves on to run the next scheduled macro.
case 2: if the file is already opened and the macro is trying to save the same file after running through the scheduler...i just get a pop up message saying that "the file is already locked by another user". The code DOES NOT trap the error and DOES NOT MOVE ON to execute the next shceduled macro.
in the above code...the macro is trying to save it as a pdf file but if this file is already opened by some user...then i just get pop and everything freezes and error doesnt get trapped...
are there any work arounds for this situation...
Thanks
-DNG
I have this following code...i have already included error handling and thanks to DoubleD who helped me with this. BUT
Code:
Sub main()
On Error GoTo Err_here
Dim objImpApp As Object
Dim objImpRep As Object
Dim objPDFPub As Object
Dim strRpt As String
strRpt="path to imr file"
Set objImpApp = CreateObject("CognosImpromptu.Application")
objImpApp.Visible 1
objImpApp.OpenCatalog "path to catalog", , , "username", "password", -1
Set objImpRep = objImpApp.OpenReport(strRpt)
Set objPDFPub = objImpRep.PublishPDF
filepath = "\\blah\Reports\"
filename = "Activations" + ".pdf"
objPDFPub.Publish filepath & filename
objImpRep.CloseReport
Exit_Here:
objImpApp.Quit
Set objImpApp = Nothing
Set objImpRep = Nothing
Set objPDFPub = Nothing
Exit Sub
Err_Here:
Open "C:\ErrLogFile.txt" For Append As #1
Print #1, "Error occured while running " & strRpt & "."
Print #1, "Error #:" & Err & " " & Error$
Print #1, "Error occured at " & Now() & "."
Print #1, "********** End Of Error ***********"
Close #1
Resume Exit_Here
End Sub
the code does not work in all cases...
for example:
case 1: if there is any error in the file path or if there is any error in the printer(if i am trying to print my report) the code traps the error and logs it and moves on to run the next scheduled macro.
case 2: if the file is already opened and the macro is trying to save the same file after running through the scheduler...i just get a pop up message saying that "the file is already locked by another user". The code DOES NOT trap the error and DOES NOT MOVE ON to execute the next shceduled macro.
in the above code...the macro is trying to save it as a pdf file but if this file is already opened by some user...then i just get pop and everything freezes and error doesnt get trapped...
are there any work arounds for this situation...
Thanks
-DNG