Thank you ranman256. here is the actual code shared to me and appreciate if how code shared will be added on the existing macro. thank you.
Sub FillWorkshopPDFForm()
Dim PDFTemplateFile As String, NewPDFFile As String, SavePDFFolder As String, StudentName As String
Dim Subj As String, Mesg As String, EmailAdd As String
Dim StudentRow As Long, LastRow As Long
Dim OutApp As Object, OutMail As Object
If Sheet1.Range("E5").Value = Empty Then
MsgBox "Please select a PDF Template to use"
SetPDFTemplate
If Sheet1.Range("E5").Value = Empty Then Exit Sub
End If
PDFTemplateFile = Sheet1.Range("E5").Value 'Template File Name
With Sheet2
LastRow = .Range("A9999").End(xlUp).Row 'Last Student Row
ThisWorkbook.FollowHyperlink PDFTemplateFile
Application.Wait Now + 0.00002
For StudentRow = 3 To LastRow
If .Range("H" & StudentRow).Value = Empty Then
StudentName = .Range("A" & StudentRow).Value 'Student Name
EmailAdd = .Range("F" & StudentRow).Value 'Email Address
Subj = Replace(Sheet1.Range("E7").Value, "#Name#", StudentName) 'Email Subject
Mesg = Replace(Sheet1.Range("E9").Value, "#Name#", StudentName) 'Email Message
NewPDFFile = ThisWorkbook.Path & "\" & StudentName & "_Enrollment.pdf" 'New File Name
If Dir(NewPDFFile, vbDirectory) <> "" Then Kill (NewPDFFile) 'Deleted File if exists
'Clear Form
Application.Wait Now + 0.00001
Application.SendKeys "%"
Application.Wait Now + 0.00001
Application.SendKeys "M"
Application.Wait Now + 0.00001
Application.SendKeys "F"
Application.Wait Now + 0.00001
'Add fields
Application.SendKeys "{Tab}", True
Application.SendKeys StudentName, True
Application.Wait Now + 0.00001
Application.SendKeys "{Tab}", True
Application.SendKeys EmailAdd, True
Application.Wait Now + 0.00001
Application.SendKeys "{Tab}", True
Application.SendKeys Format(.Range("G" & StudentRow).Value, "###-###-####"), True 'Phone #
Application.Wait Now + 0.00001
Application.SendKeys "^+(s)", True
Application.Wait Now + 0.00001
Application.SendKeys NewPDFFile, True
Application.Wait Now + 0.00002
Application.SendKeys "%(s)" 'Save As
Application.Wait Now + 0.00002
'Create Emaiol
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = EmailAdd
.Subject = Subj
.Body = Mesg
.Attachments.Add NewPDFFile
If Sheet1.Range("B5").Value = True Then .Display Else .Send 'Send or Display Email
End With
.Range("H" & StudentRow).Value = Now 'Set Current Date & Time
AppActivate "Foxit Reader"
End If
Next StudentRow
Application.SendKeys "^(q)", True
Application.SendKeys "{numlock}%s", True
End With
End Sub