LoopPrint PDF to LoopPrint to Printer

GRL87

New Member
Joined
Oct 6, 2020
Messages
7
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi

I'm fairly basic with VBA and someone very kindly wrote the following code that would export all reports from a drop down list into single PDF's which is great but I need to change it so that it prints to a physical printer instead. Can anyone tell me what I would change for it to go to a printer? I have tried to use print out, print all and I only get the current data that I have selected, I can't get the loop to work. Many thanks.

Sub LoopPrintPDF()

response = MsgBox("Are you sure you want to print EVERY student to PDF?", vbYesNo)

If response = vbNo Then
MsgBox ("Printing Cancelled")
Exit Sub
End If

Sheets("Input page").Select
Range("D9").Select
Do
Selection.Copy
Sheets("Individual PLCs").Select
Range("A3").Select
ActiveSheet.Paste
Application.CutCopyMode = False
'ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True

Dim sFileName As String
Const MyFolder As String = "P:\staff\PLC 2020\Y11 PDF Bulk Print\"

With Sheets("Individual PLCs")
sFileName = Range("A4").Value

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=MyFolder & sFileName, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
End With

Sheets("Input page").Select

ActiveCell.Offset(1, 0).Select

'Loop Until IsEmpty(ActiveCell.Offset(0, 1))
Loop Until (ActiveCell.Offset(0, 0) = "")
Sheets("Individual PLCs").Select
End Sub
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Hi,

I'm no pro like these other guys but try this real quick to see if it works:

Sub LoopPrintPDF()

response = MsgBox("Are you sure you want to print EVERY student to PDF?", vbYesNo)

If response = vbNo Then
MsgBox ("Printing Cancelled")
Exit Sub
End If

Sheets("Input page").Select
Range("D9").Select
Do
Selection.Copy
Sheets("Individual PLCs").Select
Range("A3").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True

Sheets("Input page").Select

ActiveCell.Offset(1, 0).Select

'Loop Until IsEmpty(ActiveCell.Offset(0, 1))
Loop Until (ActiveCell.Offset(0, 0) = "")
Sheets("Individual PLCs").Select
End Sub
 
Upvote 0
This works! Thank you so much - I spent many hours trying to delete bits to make it work. It is definitely something that I need to develop!

Thanks
 
Upvote 0

Forum statistics

Threads
1,214,812
Messages
6,121,696
Members
449,048
Latest member
81jamesacct

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