Results 1 to 3 of 3

Thread: Convert a Specific Sheet to PDF but with Special Criteria
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Apr 2019
    Posts
    13
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Post Convert a Specific Sheet to PDF but with Special Criteria

    Hello,

    Ill try an explain this as best I can.

    I need to open a workbook remotely called "Main Monthly File May2019_pre sonia.xlsx" select the sheet "Covered Bonds Movements" then set the print range "A1:H130" and then convert that area to PDF but the kicker is the PDF has to be 1 A4 sheet with two pages on it if that makes sense. So the top half of the print area on the left and the bottom half on the right.


    I cannot seem to get VBA to do this but there has to be away. I have put the basic code below which works fine it just doesn't put both halves side by side.
    I know this isn't using the printer but there must be away to do it via this method?


    Code:
    Dim filepath1 As String
    Dim filename1 As String
    Dim outputfile1 As String
    Dim filepath8 As String
    Dim filename8 As String
    Dim outputfile8 As String
    
    
    filepath8 = Range("C14")
    filename8 = Range("F14")
    outputfile8 = Range("F14")
    
    
    Application.AskToUpdateLinks = False
    Application.DisplayAlerts = False
    Workbooks.Open (filepath8)
    Sheets("Covered Bonds Movements").Range("A1:H131").ExportAsFixedFormat Type:=xlTypePDF, _
    Filename:=(outputfile8)
    ActiveWindow.Close
    
    
    End Sub

  2. #2
    Board Regular sykes's Avatar
    Join Date
    May 2002
    Location
    Cornwall,England
    Posts
    1,560
    Post Thanks / Like
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Convert a Specific Sheet to PDF but with Special Criteria

    Most machines come with some kind of PDF printer software, nowdays - such as "Microsoft Print to PDF." Not sure whether this ships with Windows, or when you load one of the Adobe applications, but it's always there on the machines that I've used.

    If you have this on your machine(s), couldn't you just write a bit of VBA to temporarily change to this printer (just been helping on another post, on this subject, funnily enough) then print to it, specifying the destination, and specifying printing 2 pages per sheet, having split your worksheet area into 2 pages?
    Sykes
    Windows 10 / XL 2016
    Members don't have crystal balls, so PLEASE describe your situation, code,
    and requirements ACCURATELY in your first post. It saves hair!
    Better still - upload your spreadsheet (and formulae!) with this great bit of kit.


    - forum use guidelines, forum rules and terms of use
    - Try searching for your answer first, see how
    - Read the FAQs
    - List of BB codes

  3. #3
    New Member
    Join Date
    Apr 2019
    Posts
    13
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Convert a Specific Sheet to PDF but with Special Criteria

    I do have Adobe PDF printer on the machines thats fine but when I have tried the .TwoPagesOnOne = True the script just falls over.

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
  •