PDF Create button to manage output formatting

grabrail

Board Regular
Joined
Sep 6, 2010
Messages
128
Office Version
  1. 365
Platform
  1. Windows
Hi

I have a workbook that contains multiple sheets. we have on the road engineers that use these workbooks for complete inspections.

There are x amount of inspection worksheets
there is a summary page
there is a title page

I currently have a Create PDF button, using the code below that creates a pdf of only inspection sheets that have been completed.

VBA Code:
Sub Button12_Click()
Dim ws As Worksheet
  Dim strWS As String
  Dim strFolder As String
  Dim varRet As Variant
  
  Const cstrDel As String = ","
  
  'getting information about the sheets that begin with "DPU Report"
  For Each ws In Worksheets
    If Left(ws.Name, 10) = "DPU Report" And ws.Range("C6").Value <> "" Then
      strWS = strWS & ws.Name & cstrDel
    End If
  Next ws
  
  'getting the folder to which to save to
  With Application.FileDialog(msoFileDialogFolderPicker)
    If .Show = -1 Then
      strFolder = .SelectedItems(1) & "\"
    Else
      Exit Sub
    End If
  End With
  
  'getting the filename to save
  varRet = Application.GetSaveAsFilename(InitialFileName:=strFolder, _
            fileFilter:="PDF Files (*.pdf), *.pdf", _
            Title:="Save Report to Directory")
  
  'if Cancel is chosen varRet will return False
  If varRet <> False Then
    'group the worksheets
    Worksheets(Split(Left(strWS, Len(strWS) - 1), cstrDel)).Select
    'print to PDF
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
        Filename:=varRet, _
        Quality:=xlQualityStandard, _
        IncludeDocProperties:=True, _
        IgnorePrintAreas:=False, _
        OpenAfterPublish:=True  'display after creation?
  End If
End Sub

This works perfectly

However, our admin people in the office also create a PDF for management, that contains the summary and title page. They dont use the button for this, they use print to PDF option instead.

The problem I am having is that we use the "Fit all rows on one page" to create this PDF, and for the inspection sheets this is fine, however the summary and title page span multiple pages at normal size, but to make all rows fit one page it obviously compresses the pages and they look terrible

So my question is, can I expand on this button above so I can pdf all the inspection sheets as they are, but also so add the summary page and title page without the fit to one page option?
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college

Forum statistics

Threads
1,223,886
Messages
6,175,194
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top