Close PDF Complete Viewer

JSmith

New member
Joined
Jul 11, 2013
Messages
2
Reaction score
0
Points
0
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
 
I don't know anything about PDF Complete, as I've never dealt with that one before.

I'm curious... your code looks like it is sending to the printer, and then you're trying to use SendKeys to click OK on the commands that pop up when the PDF software opens. Is that right?

If that's the case, I would HIGHLY recommend that you switch your PDF creation software to one that has an actual VBA library to code against. Personally, I use PDFCreator, which is a free PDF Writer from SourceForge, and I've got a bunch of examples of routines here to work with it. Not sure if your'e interested in switching out, but I don't have issues with PDFCreator binding up or opening Adobe.
 
Yes, that is correct. I am trying to use SendKeys to copy and paste the value of a cell as the file name and then hit enter to save it. I was reviewing your codes the last few days, but I was not able to get it to work with what I am trying to do. Sorry, I am new to the VBA code writing. I downloaded PDFComplete and tried using the my code with PDFComplete as the printer, but now the SendKeys is not pasting the file name or saving it. Any suggestions?
 
Honestly, if you're new to this, you have the ability to install your software, and you haven't used PDF Complete much either, I'd uninstall PDF Complete, install PDFCreator (the link is in the article), and get us to help you build a solution using PDFCreator. You'll find it WAY more stable than trying to use SendKeys. (Also, FYI, the code base for PDFCreator is specific to that program, so it won't work with anything else.)

If you're game for that, tell us what you're trying to accomplish? Create multiple PDF's at once? Create a single PDF from multiple sheets? What's the scenario that drives things? I'm certain we can do it with PDFCreator.
 
PDF forms

I discovered a site where there are searchable and fillable pdf forms.
 
You might be interested as well because I was able to search for forms and fill it out.
 
PDF complete? There is another one I discovered and I think it is much better.
 
Sorry If i keep on posting it is not allowing me to show you the link that you can follow.
 
Back
Top