Excel VBA print to "PDF Printer"?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ladams1949
    New Member
    • Nov 2008
    • 2

    #1

    Excel VBA print to "PDF Printer"?

    In Excel, I need to
    1. Select "PDF printer" from the printer list when printing a page
    2. Recognize when the "Save As" window comes up
    3. And then Sendkeys "finename~" to save the PDF file.

    I have step 3, but I need help with 1 and 2. Thoughts? Thanks.
  • ladams1949
    New Member
    • Nov 2008
    • 2

    #2
    Just me again. I found an answer for 1. I just need 2. I should add that this is in VBA and Excel 2003.

    Again, I just need to be able to recognize when a window captioned "Save As" appears so that I can then use sendkeys to provide the desired filename.

    Thanks.

    Comment

    • ubentook
      New Member
      • Dec 2007
      • 58

      #3
      You can trap for the display of the SaveAs dialog box in the ThisWorkbook Before Save event.
      You can then display the SaveAs dialog box and include the file name to be used...
      '--
      'In the ThisWorkbook module...
      Private Sub Workbook_Before Save(ByVal SaveAsUI As Boolean, Cancel As Boolean)
      On Error GoTo OutOfHere
      If SaveAsUI Then
      Application.Ena bleEvents = False
      Cancel = True
      Call MySubstituteSub
      End If
      OutOfHere:
      Application.Ena bleEvents = True
      End Sub
      '--

      'In a standard module...
      Sub MySubstituteSub ()
      Application.Dia logs(xlDialogSa veAs).Show "My File Name"
      End Sub

      Comment

      Working...