Excel Sheet import to PDF sheet

chrisl614

Member
Joined
Apr 6, 2019
Messages
30
Reaction score
0
Points
6
Excel Version(s)
2016
Hi
I have an excel sheet that that I want to be able to import into excel. I don't want to convert the excel sheet to PDF, I want to know if I would be able to import the excel sheet into the PDF form.
Thank you in advance
 

Attachments

  • Excel Test.xlsx
    11.1 KB · Views: 8
  • test pdf.pdf
    372.3 KB · Views: 6
.
Paste the following into a Regular Module :

Code:
Option Explicit

Sub PrintTableToPDF()
'SUBROUTINE: PrintTableToPDF
'DEVELOPER: Ryan Wells
'DESCRIPTION: Print a table of your choosing to a PDF


Dim strfile As String
Dim myfile As Variant
Dim strTable As String, r As Range
Application.ScreenUpdating = False


'Enter the table name you want to save
strTable = InputBox("What's the name of the table you want to save?", "Enter Table Name") 'Table you want to save
    If Trim(strTable) = "" Then Exit Sub
        'Prompt for save location
        strfile = strTable & "_" _
        & Format(Now(), "yyyymmdd_hhmmss") _
        & ".pdf"
        strfile = ThisWorkbook.Path & "\" & strfile
        
        myfile = Application.GetSaveAsFilename _
        (InitialFileName:=strfile, _
        FileFilter:="PDF Files (*.pdf), *.pdf", _
        Title:="Select Folder and File Name to Save as PDF")
        
            If myfile <> "False" Then 'save as PDF
                Range(strTable).ExportAsFixedFormat Type:=xlTypePDF, Filename:=myfile, Quality:=xlQualityStandard, _
                IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
            Else
                MsgBox "No File Selected. PDF will not be saved", vbOKOnly, "No File Selected"
            End If


Application.DisplayAlerts = False


LetsContinue:
    With Application
        .ScreenUpdating = True
        .DisplayAlerts = True
    End With
Exit Sub
End Sub

You will need to highlight all of the table to be included and give it a name. Go to the INSERT tab on the menu bar and select TABLE. You will click on TABLE after you have highlighted all of the RANGE to be included in the table.

After creating the Table, give it a name or accept the auto-name. If it is the first one it will be called TABLE1.
Then run the macro.

This is the source for the code : https://trumpexcel.com/convert-excel-to-pdf/

Scroll down a couple of times to : Print One Table To PDF

Best wishes.
 
Back
Top