使用“ Microsoft打印为PDF”进行打印

时间:2019-08-05 13:47:57

标签: qlikview

我想尝试在宏中打印出带有“ Microsoft Print to PDF”的报告。我在www中发现了一些无法正常运行的脚本,但似乎很好。我测试过,但是有问题。我必须插入输出文件的名称和路径。

我从头开始的代码在此链接https://community.qlik.com/t5/New-to-QlikView/Report-to-PDF-using-Microsoft-Print-to-PDF/td-p/128644中,我如下进行了更改。

Private Sub Print_PDF(FieldValue, ReportName, ReportID)

    Dim sPDFName
    Dim reportFile
    sPDFName = ReportName & "-" & FieldValue

    'ActiveDocument.reload  
    ActiveDocument.PrintReport(ReportID), "Microsoft Print to PDF", false  'Printreport
    reportFile = "C:\Users\ITMILSBOR\" & sPDFName &".pdf" 'Setting outputname  
    MyPrint(reportFile) 'Call pdf printer 
    ActiveDocument.GetApplication.Sleep 5000  
    ActiveDocument.Save  
    ActiveDocument.GetApplication.Sleep 5000  
    ActiveDocument.GetApplication.Quit  

end Sub

FUNCTION MyPrint (pdfOutputFile)  

    Dim obj

    'set obj = CreateObject("Microsoft Print to PDF.PDFPrinterSettings")
    set obj = CreateObject("Shell.Application").Namespace(0).ParseName(strF).InvokeVerb ("Print")  
    obj.SetValue "Output" , pdfOutputFile  
    obj.SetValue "ConfirmOverwrite", "no"  
    obj.SetValue "ShowSaveAS", "never"  
    obj.SetValue "ShowSettings", "never"  
    obj.SetValue "ShowPDF", "no"  
    obj.SetValue "RememberLastFileName", "no"  
    obj.SetValue "RememberLastFolderName", "no"  
    obj.SetValue "ShowProgressFinished", "no"  
    obj.SetValue "ShowProgress", "no"  
    obj.WriteSettings True  

END FUNCTION

当代码调用该行时 “ ActiveDocument.PrintReport(ReportID),” Microsoft打印到PDF“,false” 系统将打开与如何保存文件有关的对话框。 有人可以帮助我吗?

0 个答案:

没有答案