访问问题:输出在访问2007中不起作用

时间:2011-06-06 21:45:16

标签: ms-access-2007

我在访问2010中使用此代码生成pdf文件  DoCmd.OutputTo acOutputReport,“Graph_report2”,“。pdf”,“C:\ Graph_report2.pdf”,True

它在访问2010中工作正常但是当我在访问2007中打开我的访问数据库时,它给出了运行时错误2501'输出操作已被取消'而不是pdf文件已打开。

大问题!我做什么? Plz帮助

2 个答案:

答案 0 :(得分:2)

DoCmd.OutputTo acOutputReport, "Graph_report2", ".pdf", "C:\Graph_report2.pdf", True

应该是:

DoCmd.OutputTo acOutputReport, "Graph_report2", acFormatPDF, "C:\Graph_report2.pdf", True

罗布

答案 1 :(得分:0)

除了需要为PDF输出安装插件然后启动Access 2007,http://www.microsoft.com/en-us/download/details.aspx?id=9943

之外,我可以添加吗?

如果试图将文件保存在不存在的目录中,也会弹出此错误。

这是PDF输出的功能:

    Function PrintToPDF(SrcReport As String, DestPath As String, DestFile As String, ShowPdf As Boolean)
    On Error GoTo PrintToPDF_Err

    'ScrReport = The report Name to output as PDF
    'DestPath = Destination path for PDF file e.g. C:/DatabaseReports/Financial/
    'DestFile = File name for the PDF file being created, but without the file extension, one can add date to it
    'Showpdf = launch pdf viwer and display this PDF output

    DoCmd.OutputTo acOutputReport, SrcReport, "PDFFormat(*.pdf)", DestPath & DestFile & ".pdf", ShowPdf, "", 0, acExportQualityPrint

  PrintToPDF_Exit:
    Exit Function

  PrintToPDF_Err:
    MsgBox Error$
    Resume PrintToPDF_Exit


   End Function