+ Reply to Thread
Results 1 to 8 of 8

Blank Pages Saved As PDF

Hybrid View

  1. #1
    Registered User
    Join Date
    07-25-2019
    Location
    San Diego, CA
    MS-Off Ver
    16.0.11727.20222
    Posts
    34

    Blank Pages Saved As PDF

    Hey all!

    I've written a code to save a couple of selected pages as PDFs. My code works, saving it in the correct file path with the correct names and all. The problem is, the saved PDF has a third, blank page, when there should only be two. The selected ranges on both sheets go up to 46, and both are on one page, so I know it's not that.

    Private Sub ConsentPDF_Click()
    Dim Path As String
    Dim FileName1 As String
    Dim FileName2 As String
    Dim FileName3 As String
    Path = "O:\LAB\Label Tracking\Mailed Forms\"
    FileName1 = "Use & Destruction Consent"
    FileName2 = Sheets("Use Consent").Range("B2")
    FileName3 = Sheets("Use Consent").Range("F2")
    
    Sheets("Use Consent").Activate
    ActiveSheet.UsedRange.Select
    Sheets("Destruction Consent").Select
    ActiveSheet.UsedRange.Select
    
    ThisWorkbook.Sheets(Array("Use Consent", "Destruction Consent")).Select
    Selection.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Path & FileName1 & " - " & FileName2 & " - " & FileName3 _
        , Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
    End Sub
    Thank you for any help!
    Attached Files Attached Files
    Last edited by hindotmo12; 08-26-2019 at 11:56 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    12-14-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2007
    Posts
    439

    Re: Blank Pages Saved As PDF

    Hi,

    In this case, nobody can know where the mistake is if you don't attach the real workbook.

  3. #3
    Registered User
    Join Date
    07-25-2019
    Location
    San Diego, CA
    MS-Off Ver
    16.0.11727.20222
    Posts
    34

    Re: Blank Pages Saved As PDF

    Hi,

    Sorry about that, I guess I just assumed it would be a coding issue. I've just updated the OP with the attachment.

  4. #4
    Valued Forum Contributor
    Join Date
    12-14-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2007
    Posts
    439

    Re: Blank Pages Saved As PDF

    Your workbook has a strange error. Hide all unused rows and columns may be helpful.

  5. #5
    Registered User
    Join Date
    07-25-2019
    Location
    San Diego, CA
    MS-Off Ver
    16.0.11727.20222
    Posts
    34

    Re: Blank Pages Saved As PDF

    What/where is the error? I don't think I can hide unused rows, as the sheets are formatted to be used as forms. It's such a basic sheet right now, maybe I ought to just start from scratch?

    Thank you

  6. #6
    Registered User
    Join Date
    07-25-2019
    Location
    San Diego, CA
    MS-Off Ver
    16.0.11727.20222
    Posts
    34

    Re: Blank Pages Saved As PDF

    I ran into errors when I would run the code twice, telling me to debug. I think it didn't want to save the same file name over an existing file. It caused Excel to freeze, and even froze my library folder. Maybe that did it?

  7. #7
    Valued Forum Contributor
    Join Date
    12-14-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2007
    Posts
    439

    Re: Blank Pages Saved As PDF

    Hi Hindotmo,

    I have encountered this error. The error is if you fit the contents into 1 page, when printing the contents will be zoom out. I don't know why.

  8. #8
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Blank Pages Saved As PDF

    After sheets are group selected, use ActiveSheet. The other Activate and Select are not needed.
    Private Sub ConsentPDF_Click()
        Dim Path As String
        Dim FileName1 As String
        Dim FileName2 As String
        Dim FileName3 As String
        
        Path = "O:\LAB\Label Tracking\Mailed Forms\"
        FileName1 = "Use & Destruction Consent"
        FileName2 = Sheets("Use Consent").Range("B2")
        FileName3 = Sheets("Use Consent").Range("F2")
        
        ThisWorkbook.Sheets(Array("Use Consent", "Destruction Consent")).Select
        ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Path & FileName1 & " - " & FileName2 & " - " & FileName3 _
            , Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Copy Data from Saved Multiple Web Pages to MS-Excel sheet wise
    By srikanthk in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-18-2015, 01:38 AM
  2. VBA to open saved web html pages - extract text - paste text within individual cell
    By EddieRubi in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 07-23-2015, 01:43 PM
  3. Replies: 1
    Last Post: 09-12-2012, 06:29 PM
  4. blank pages
    By jemma in forum Excel General
    Replies: 1
    Last Post: 10-24-2006, 07:32 PM
  5. How do I get rid of all of the blank pages?
    By stkelly52 in forum Excel General
    Replies: 5
    Last Post: 04-15-2006, 08:20 AM
  6. [SOLVED] how do I add blank pages to
    By rozan in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 03-01-2006, 04:50 PM
  7. [SOLVED] Blank Worksheet Pages
    By EricRod in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 07-26-2005, 06:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1