Printing to multiple PDF files

kamenitxan

New member
Local time
Today, 12:30
Joined
Jul 8, 2013
Messages
4
Hi,
my report has tens of pages and I need to save each page as separate file with ID as filename.

I searched internets for solution but I something I´m doing wrong. PDF prints with ID but all in one file. I use this code.

Can you help me? Thanks a lot

Code:
Option Compare Database
Private Sub tisk()
    Dim cesta As String
    Dim kod As String
    Dim Sql As String
    Dim rs As Recordset
    Dim tisknute As String
    
  DoCmd.OpenReport "toner", acViewPreview
    
    cesta = "C:\Documents and Settings\tomas\Plocha\"
    kod = Reports![toner].text13
    Sql = "SELECT DISTINCT * FROM toner ORDER BY ID"
    tisknue = "SELECT ID FROM toner"
    
    Set rs = CurrentDb.OpenRecordset(Sql)

    With rs
        .MoveLast
        .MoveFirst

    Do Until .EOF = True

        DoCmd.OutputTo acOutputReport, "toner", acFormatPDF, cesta + kod + ".pdf", True

        .MoveNext
    Loop

    End With
    rs.Close

End Sub
 
It is not about the code.
It is about the report's design.
In design view, move the ID text box under (in) the section Page Header.
 
Ok. I have now pages with different ID in header. But still I dont know, how to export each page as separate PDF file.
 
You need to filter your report in preview, then save your PDF and close the report, like:
Code:
Do Until .EOF = True

        DoCmd.OpenReport "toner", acPreview, , "ID =" & rs!ID        
        DoCmd.OutputTo acOutputReport, "toner", acFormatPDF, cesta & kod & rs!ID & ".pdf", True
        DoCmd.Close acReport, "toner"
        .MoveNext
Loop

Also to join text use & to prevent suprises
 
I have little problem with it.
First exported PDF contain all report pages.
Following files contain one report page, as I want.

I have no idea, wher is the problem.
 

Users who are viewing this thread

Back
Top Bottom