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