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

Macro Publish to PDF errors: R438, R91

Status
Not open for further replies.

tiedyelime

Programmer
May 8, 2006
6
0
0
US
I am having trouble with this...getting a few errors. Here's the entire macro...
Declare Sub GeneratePDF()

Declare Sub SendIt()

Dim objImpApp as Object
Dim objImpRep as Object
Dim objPDFPub as Object
Dim ImpPDFRep as Object

Dim strPDFFileName As String
Dim strImrSource as String
Dim strFileSource as String
Dim strFileDest as String

Dim objOutlook As Object
Dim objOutlookMsg As Object
Dim strMsgSubject, strDistList, ReportPDF As String

Sub Main()
Set objImpApp = CreateObject("CognosImpromptu.Application")
objImpApp.Visible True

'Open catalog
objImpApp.OpenCatalog "D:\Cognos\cer4\PowerPrompts Apps\Lawson Production.cat","User",,"ANLYTICS","*****",-1

strImrSource = "D:\Cognos\cer4\PowerPrompts Apps\Field Labor Invoices.imr"
strFileSource = "D:\CognosReports\Commissioning Services\Commissioning Services.pdf"
strFileDest = "\\CorpHQFS05\Temp90\SBS\Commissioning Services.pdf"
Call GeneratePDF
FileCopy strFileSource,strFileDest

strDistList = "SBSInvoicingList"

Call SendIt

objImpApp.Quit
Set objImpApp = Nothing
Set objImpRep = Nothing
Set objOutlook = Nothing
Set objOutlookMsg = Nothing

End Sub

Sub GeneratePDF()
Set objImpRep = objImpApp.OpenReport(strImrSource)
objImpRep.Reexecute
Set objPDFPub = objImpRep.PublishPDF
ImpPDFRep.Version 0
ImpPDFRep.ExportOptions 15
ImpPDFRep.Publish strPDFFileName & ".pdf"
strPDFFileName = Left$(objImpRep.FullName, Len _
(objImpRep.FullName) - 4)
objPDFPub.Publish strPDFFileName & ".pdf"
ReportPDF = strPDFFileName & ".pdf"
objImpRep.Save
objImpRep.CloseReport
End Sub

Sub SendIt()

Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
objOutlook.Session.Logon "YI046180", "*****", False, True
With objOutlookMsg
.To = strDistList
.Subject = "Commissioning Services Invoices Awaiting Approval Report"
.Body = "The Report is Attached as a PDF file."
.Attachments.Add ( ReportPDF )
.Send
End With

End Sub

 
Might one enquire on which of the lines the error message(s) occur and the text that accompanies the message?

(If unsure, you can always error-trap with the 'On Error' command and the variables 'Err' for error & 'Erl' for the line)


soi la, soi carré
 
Thanks for helping. The error is on the line:

ImpPDFRep.Version 0
 
See other post concerning this Property and .ExportOptions one.

soi la, soi carré
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top