Consulting

Results 1 to 2 of 2

Thread: Macro to Save Only a Certain Range of Pages of DOCX to PDF

  1. #1
    VBAX Newbie
    Joined
    Jan 2019
    Posts
    1
    Location

    Macro to Save Only a Certain Range of Pages of DOCX to PDF

    Hello!

    I currently have a Macro that allows me to go to the "Save As PDF" automatically. However, I want to be able to code in the macro to only save pages 2-8 and convert to PDF. I don't want the Macro to actually save it, I want to get to the "Save As" page but have all the options that I want already preselected (save as PDF and convert only pages 2-8). Any help is appreciated:

    This is what I currently have:

    Sub CreateProposal()
    '
    ' CreateProposal Macro
    '
    '
    With Dialogs(wdDialogFileSaveAs)
    .Format = wdFormatPDF
    .Show
    End With


    End Sub

  2. #2
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    The SaveAs dialogue doesn't take arguments for a PDF save range. Instead, you need a brute-force approach:
    Sub CreateProposal()
    SendKeys "%fa{TAB}p%og{TAB}2{TAB}8{ENTER}"
    End Sub
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •