I have created a VBA to print pdfs for names from a drop down list and save it based on a cell value. I have everything working. Currently must close the PDF viewer in order for the next drop down item to print correctly. I have 300 names in the drop down and instead of closing the viewer I am now trying to find a way to close my PDF viewer automatically in the code. I have tried several ways, but can't seem to get it to work. Any guidance would be greatly appreciated. Here is what I have currently.
Code:
Sub SavePDF()
'
' SavePDF Macro
' Macro recorded 7/09/13
'
'
Dim n As Integer
With Worksheets("Capital Summary")
Sheets("Capital Summary").Select
Range("B2:K43").Select
ActiveSheet.PageSetup.PrintArea = "$B$2:$K$43"
'loop through names for drop-down
For n = 0 To Range("M8").Value
'drop down in E4 and first name in list in Q6
'change as required.
'apply each name to drop-down cell
.Range("E4") = .Range("Q6").Offset(n, 0).Value
'print each record (uses current printer)
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, ActivePrinter:="PDF Complete"
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 5
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime
Filename = ActiveWorkbook.Path & Application.PathSeparator & ActiveSheet.Range("M7").Value
SendKeys Filename & "{ENTER}", False
Application.Wait waitTime
OpenAfterPublish = False
Next n
End With
End Sub