force PDF save to be at top of page ???

palaeontology

Active Member
Joined
May 12, 2017
Messages
444
Office Version
  1. 2016
Platform
  1. Windows
I'm using the following code to save any worksheet (named with a 5-digit code) as a PDF in a given location ..

Code:
Dim wPath As String, r1 As String, r2 As String, r3 As String    
    wPath = "G:\Maths Dept\STUDENT RESULTS\2019\PDF Profile Copies\"
    For Each ws In ThisWorkbook.Worksheets
        If ws.Name Like "#####" Then
            r1 = ws.Range("S5") & "\"
            r2 = r1 & ws.Range("E2") & "\"
            r3 = r2 & ws.Range("S3") & "\"
            If Dir(wPath & r1, vbDirectory) = "" Then MkDir wPath & r1
            If Dir(wPath & r2, vbDirectory) = "" Then MkDir wPath & r2
            If Dir(wPath & r3, vbDirectory) = "" Then MkDir wPath & r3
          
            ws.PageSetup.Orientation = xlLandscape
            ws.Range("A1:ai29").ExportAsFixedFormat xlTypePDF, wPath & r3 & ws.Name & ".pdf"
        End If
    Next ws

When I view the PDF image in Adobe Acrobat, the image appears at the top of the available screen, but if I insert the PDF as a Printout into a OneNote page, it appears centered vertically, so the user needs to scroll down to see it.

It may be a OneNote issue, but I'd like to explore if forcing Excel to save the image at the top of a PDF format changes anything.

Is there a way to add to my code (above) so that it forces the save at the top of the PDF page ?

Kind regards,

Chris
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

Forum statistics

Threads
1,214,540
Messages
6,120,106
Members
448,945
Latest member
Vmanchoppy

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