VBA to print as single PDF

sjp1979

New Member
Joined
Oct 16, 2013
Messages
28
Hi All

I have a document that creates multiple documents in a mail merge type action.

I'd like these output as a single PDF for printing later.

The code I'm currently running outputs individual documents to a printer.

Code is as follows:
Code:
Sub Test()

Dim startrow As Integer, endrow As Integer, rowindex As Integer
Dim msg As String
Dim i As Integer
Dim totalrecords As String
Dim name As String, mark As String, form As String, target As String, positivecomment1 As String, positivecomment2 As String, positivecomment3 As String, progresscomment1 As String, progresscomment2 As String
totalrecords = "counta(Data!A:A)"
Range("H3") = totalrecords


startrow = 2
endrow = InputBox("Enter the last record to merge.")


If startrow > endrow Then
msg = "Error" & vbCrLf & "Silly! Your start row must be smaller than your end row!"
End If


For i = startrow To endrow
 name = Sheets("Data").Cells(i, 1)
 mark = Sheets("Data").Cells(i, 4)
 form = Sheets("Data").Cells(i, 2)
 target = Sheets("Data").Cells(i, 3)
 positivecomment1 = Sheets("Data").Cells(i, 6)
 positivecomment2 = Sheets("Data").Cells(i, 7)
 positivecomment3 = Sheets("Data").Cells(i, 8)
 progresscomment1 = Sheets("Data").Cells(i, 9)
 progresscomment2 = Sheets("Data").Cells(i, 10)
 
 Sheets("Page").Range("B7") = name
 Sheets("Page").Range("g8") = form
 Sheets("Page").Range("b9") = mark
 Sheets("Page").Range("g9") = target
 Sheets("Page").Range("B13") = positivecomment1
 Sheets("Page").Range("B16") = positivecomment2
 Sheets("Page").Range("B19") = positivecomment3
 Sheets("Page").Range("B23") = progresscomment1
 Sheets("Page").Range("B35") = progresscomment2
 
 
 ActiveSheet.PrintPreview
 
 Next i


End Sub

The file can be found here

Please help!

Thanks

Stephen
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Thanks ranman

I guess I won't be able to do it that way then.

Do you know if they could output to a single word document?

Cheers
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top