Results 1 to 9 of 9

Thread: VBA Export PDF Help

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #4
    VBAX Mentor
    Joined
    Nov 2022
    Location
    The Great Land
    Posts
    443
    Location
    Try this:
    Sub RangeToPDF()
        Selection.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
        GetFolder() & "\" & InputBox("Enter text to use as file name without extension", "Enter text", "MyFileName") & ".pdf", _
        Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
    End Sub
    
    
    Function GetFolder() As String
        Dim fldr As FileDialog
        Dim sItem As String
        Set fldr = Application.FileDialog(msoFileDialogFolderPicker)
        With fldr
            .Title = "Select a Folder"
            .AllowMultiSelect = False
            .InitialFileName = Application.DefaultFilePath
            If .Show <> -1 Then GoTo NextCode
            sItem = .SelectedItems(1)
        End With
        NextCode:
        GetFolder = sItem
        Set fldr = Nothing
    End Function
    Last edited by Aussiebear; 01-12-2025 at 01:41 PM.
    How to attach file: Reading and Posting Messages (vbaexpress.com), click Go Advanced below post edit window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Posting Permissions

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