branston
12-03-2024, 01:09 PM
Hi
Not having any joy with this so really hoping someone else can help.
My code below loops through a list of candidates and creates a pdf file for each candidate (with a specific area from my excel sheet).
The problem I have is that creating the pdfs is VERY SLOW ! It almost takes 20 seconds to create one pdf. I'm sure there is a quicker way to do this ? I have 100s of candidates.
Can anyone help me here please to make more code more efficient or for it to run faster? TIA
Public Sub Print_all_candidates()
ActiveSheet.PageSetup.PrintArea = "A1:W49"
'CYCLE THROUGH ALL CANDIDATES
With Worksheets("Main")
For i = 1 To Range("StudentName").Rows.count
.Range("F1") = i
dC = "C:\Users\tom\documents\downloads\"
FILESAVENAME = dC & "\" & i & "candidate -" & ThisWorkbook.Worksheets("Main").Range("C2").Value
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
FILESAVENAME _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
Next i
End With
Application.ScreenUpdating = True
MsgBox "All Files Created..."
End Sub
Not having any joy with this so really hoping someone else can help.
My code below loops through a list of candidates and creates a pdf file for each candidate (with a specific area from my excel sheet).
The problem I have is that creating the pdfs is VERY SLOW ! It almost takes 20 seconds to create one pdf. I'm sure there is a quicker way to do this ? I have 100s of candidates.
Can anyone help me here please to make more code more efficient or for it to run faster? TIA
Public Sub Print_all_candidates()
ActiveSheet.PageSetup.PrintArea = "A1:W49"
'CYCLE THROUGH ALL CANDIDATES
With Worksheets("Main")
For i = 1 To Range("StudentName").Rows.count
.Range("F1") = i
dC = "C:\Users\tom\documents\downloads\"
FILESAVENAME = dC & "\" & i & "candidate -" & ThisWorkbook.Worksheets("Main").Range("C2").Value
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
FILESAVENAME _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
Next i
End With
Application.ScreenUpdating = True
MsgBox "All Files Created..."
End Sub