Print bulk certificates

Dandada2602

New Member
Joined
Nov 22, 2018
Messages
13
I have played around with some VBA options but I’m not able to get what I’m looking for.

I need to print individual certificates in PDF format, from the list within the same excel file. Each line in the list should be an individual certificate. The resulting PDF file naming should have the certificate number, container number and voyage number. I would like to keep the list as a consecutive, to ensure we don’t duplicate certificate numbers. This will require that the line is marked as print completed, and new lines as print pending. If this is too much to ask for, please omit.

This is the list:

Certificate #Container #Line OperatorBookingCompletion TimeTransport CompanyVoyage #
CERT-00001ABCU1234567ABCRES-567892020/10/18 04:59Blue Point202058001
CERT-00002ABCU1234568ABCRES-567902020/10/17 21:59Blue Point202058001
CERT-00003ABCU1234569ABCRES-567912020/10/18 03:59Blue Point202058001
CERT-00004ABCU1234570ABCRES-567922020/10/18 02:59Green Point202058001
CERT-00005ABCU1234571ABCRES-567932020/10/18 03:59Green Point202058001
CERT-00006ABCU1234572ABCRES-567942020/10/18 19:59Green Point202058001
CERT-00007ABCU1234573BCCRES-567952020/10/17 06:59Green Point202058001
CERT-00008ABCU1234574BCCRES-567962020/10/17 07:59Red Point202058001
CERT-00009ABCU1234575BCCRES-567972020/10/17 18:59Red Point202058001
CERT-00010ABCU1234576BCCRES-567982020/10/19 09:59Red Point202058001
 

Attachments

  • Certificate.JPG
    Certificate.JPG
    50.1 KB · Views: 107

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Ok,

I have made some assumptions and additions.
Assumptions:
formatting for dates etc has been applied to the certificate sheet
the cert sheet info is centered across selection in the rows above table from C:F
Additions:
Data sheet got a new set of info entered into Column H, titled Print with "Pending" entered in all lines.
(the code will amend pending to complete once done)

You will need to amend a couple of variables to suit your sheet names and file path where certs should be saved.

VBA Code:
Option Explicit

Sub PrintCerts()
Application.ScreenUpdating = False
On Error GoTo Err
Dim Cert As Worksheet, Data As Worksheet
Dim LRow As Long, i As Double, svNm As String, fPath As String

Set Cert = Sheets("Certificate") 'Amend for name of certificate tab
Set Data = Sheets("Data") 'Amend for name of sheet containing your list
fPath = "/Users/cooper645/Desktop/" 'Set the filepath for where the certs should be saved"

LRow = Data.Cells(Rows.Count, "A").End(xlUp).Row 'Find the last row of data

For i = 2 To LRow
    If Data.Cells(i, 8).Value = "Pending" Then
        Cert.Range("C2").Value = Data.Cells(i, 3) 'cert heading
        Cert.Range("C8").Value = Data.Cells(i, 1) 'Cert Number
        Cert.Range("C12").Value = Data.Cells(i, 3) & " Certify the scan:" 'Certify line
        Cert.Range("C15").Value = Data.Cells(i, 2) 'Container
        Cert.Range("D15").Value = Data.Cells(i, 4) 'Booking
        Cert.Range("E15").Value = Data.Cells(i, 5) 'Completed
        Cert.Range("F15").Value = Data.Cells(i, 7) 'Voyage Number
        Cert.Range("A18").Value = "As requested by company " & Data.Cells(i, 6) & " we proceed to scan" 'Transport Company"
        Cert.Range("C22").Value = Date 'Todays date
        Cert.Range("A28").Value = "Company: " & Data.Cells(i, 3) 'Company certifying
        
            svNm = Data.Cells(i, 1) & "_" & Data.Cells(i, 2) & "_" & Data.Cells(i, 7) & ".pdf" 'Create the filename
            
            'Save PDF
            Application.PrintCommunication = True
            ChDir fPath
            ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, FileName:=fPath & svNm, _
            Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
            
                Data.Cells(i, 8).Value = "Complete" 'Mark row as completed
            
    End If
Next i

Err:
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,786
Messages
6,121,548
Members
449,038
Latest member
Guest1337

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