Saving PDF and Skipping Dialog Box

oliquino

New Member
Joined
Apr 16, 2020
Messages
9
Office Version
  1. 2016
  2. 2013
  3. 2010
Platform
  1. Windows
Hi. I'm trying to "save as" a PDF however seems that my codes are missing something and showing a dialog box I need to skip to go directly to the ThisWorkbook. Path. Im working of an Adobe Acrobat Reader DC which believe has a different short command from other apps.


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



'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 'Save As
Application.Wait Now + 0.00001
Application.SendKeys NewPDFFile, True
Application.Wait Now + 0.00002
Application.SendKeys "^(s)" 'Save
Application.Wait Now + 0.00002



Below (1st) dialog box which I need to click "choose Diff Folder...:" just to be on the next Dialog Box

1587360826115.png


(2nd) Dialog Box

1587360963920.png
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Try enclosing your code with Application.DisplayAlerts = False and Application.DisplayAlerts = True and see what happens.

VBA Code:
Application.DisplayAlerts = False
your code here
Application.DisplayAlerts = True
 
Upvote 0

Forum statistics

Threads
1,223,936
Messages
6,175,507
Members
452,650
Latest member
Tinfish

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