Results 1 to 5 of 5

Thread: print as pdf
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular
    Join Date
    Jan 2017
    Posts
    468
    Post Thanks / Like
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Default print as pdf

    hi,

    it would be fanatastic if some kind and clever person could sort the following issue i have

    print sheet 1 as a pdf (name will change each time )
    and save to c:\sheets

    hoping this is viable?
    Thank you.
    Orbis non sufficit

    Trevor3007

  2. #2
    MrExcel MVP
    Join Date
    May 2003
    Location
    USA
    Posts
    4,671
    Post Thanks / Like
    Mentioned
    5 Post(s)
    Tagged
    1 Thread(s)

    Default Re: print as pdf

    Something like this, which prints the active sheet. You need to determine what MyFileName is ahead of time.

    Code:
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:="C:\sheets\" & MyFileName & ".pdf"
    Jon Peltier
    Peltier Technical Services, Inc.
    Try Peltier Tech Charts for Excel

  3. #3
    Board Regular
    Join Date
    Feb 2002
    Posts
    3,206
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: print as pdf

    This should get you started, please feel free to test and post any question

    Sorry the codes a little rushed

    Regards
    jiuk
    Code:
    Option Explicit
    '/// Jack in the UK
    '/// A little basic start
    
    Const myFILE_TYPE As String = ".pdf"
    
    Sub TEST_PDF_SAVE()
    
    Dim mySAVE_Location As String
    Dim myFILE_NAME As String
    
    mySAVE_Location = "C:\Sheets"
    
    '/// Error check the path is correct
    If Right(mySAVE_Location, 1) <> "\" Then
            mySAVE_Location = mySAVE_Location & "\"
        End If
            
    '/// jiuk - Check Dir Exists
        Dim myFOLDER As Object
        Application.ScreenUpdating = False
        Set myFOLDER = CreateObject("Scripting.FileSystemObject")
    '// jiuk - Used to test
        If myFOLDER.FolderExists(mySAVE_Location) Then
          '  MsgBox "Exists"
        Else
            myFOLDER.CreateFolder (mySAVE_Location)
         '   MsgBox "ICreated."
        End If
    '/// jiuk - Checck DIR exists or create DIR
    
    myFILE_NAME = InputBox("Type File Name Here")
    
    '// juik - Save the Worksheet as PDF - takes few seconds
    ActiveSheet.ExportAsFixedFormat _
        Type:=xlTypePDF, _
        Filename:=mySAVE_Location _
        & myFILE_NAME _
        & myFILE_TYPE
    
    theEND:
    
    Exit Sub
    End Sub
    Free Excel based Web Toolbar available here.

    Jack in the UK
    J & R Excel Solutions
    "making Excel work for you"

  4. #4
    Board Regular
    Join Date
    Feb 2002
    Posts
    3,206
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: print as pdf

    This might be worth changing, prints only sheet 2 without selection etc

    Regards
    jiuk
    Code:
    myFILE_NAME = InputBox("Type File Name Here")
    
    '// juik - Save the Worksheet as PDF - takes few seconds
    'ActiveSheet.ExportAsFixedFormat _
    '    Type:=xlTypePDF, _
    '    Filename:=mySAVE_Location _
    '    & myFILE_NAME _
    '    & myFILE_TYPE
        
    ThisWorkbook.Sheets(2).ExportAsFixedFormat _
        Type:=xlTypePDF, _
        Filename:=mySAVE_Location _
        & myFILE_NAME _
        & myFILE_TYPE
    
    theEND:
    Free Excel based Web Toolbar available here.

    Jack in the UK
    J & R Excel Solutions
    "making Excel work for you"

  5. #5
    Board Regular
    Join Date
    Jan 2017
    Posts
    468
    Post Thanks / Like
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Default Re: print as pdf

    hello Jack in the UK,

    Sorry for the delay getting back to you & thanks for sorting. yeah it works great. Very much appreciated.
    Thank you.
    Orbis non sufficit

    Trevor3007

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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