2011-06-06 51 views
1

我已經使用此代碼訪問2010年生成PDF文件 DoCmd.OutputTo acOutputReport,「Graph_report2」,「.pdf」,「C:\ Graph_report2.pdf」,True訪問問題:輸出不能在訪問2007年

它在Access 2010中工作正常,但是當我在訪問2007年中打開訪問數據庫時,它給出運行時錯誤2501'OutputTo操作被取消',而不是pdf文件已打開。

大問題!我做了什麼? plz幫助

+1

你必須確保在PDF插件安裝於2007年 http://www.microsoft.com/downloads/en/details.aspx ?familyid = f1fc413c-6d89-4f15-991b-63b07ba5f2e5&displaylang = en – ZippyV 2011-06-06 22:03:39

+0

@ZippyV:這是實際的答案,你應該把它作爲評論而不是評論。 – 2011-06-09 01:29:19

回答

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

應該是:

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

羅布

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