Dear All,
Below you can find the code that I've written out in order to get a PDF copy of a chosen range from my excel worksheet. Could anyone tell me how they would adjust the code so that instead of having one single page with the two ranges, I could have 1 range on the first page of a PDF and the second range on the second page of that same PDF. (i.e. the PDF would have 2 pages with one range on each page.)
The execution is made via a command button (Button13_Click)
The two ranges would go from range1(A1:K77) and range2(A78:K196)
Sub Button13_Click()
Dim path As String
Dim objShell As Object, objFolder As Object, oFolderItem As Object
Dim fileName, message, title, defaultValue As String
Dim myValue As Object
Set objShell = CreateObject("Shell.Application")
' Met le text que tu veux à la place de Desired file location
Set objFolder = objShell.BrowseForFolder(&H0&, "Desired file location", &H1&)
If Not (objFolder Is Nothing) Then
path = objFolder.Self.path
message = "File name" ' Set message text
title = "File name" ' Set title text
fileName = "Export" ' Set default value.
fileName = InputBox(message, title, defaultValue)
' If user has clicked Cancel, set myValue to defaultValue
If fileName = "" Then
fileName = defaultValue
End If
fileName = path & "\" & fileName & ".pdf"
Sheets("Report").Range("A1:K196").ExportAsFixedFormat Type:=xlTypePDF, fileName:=fileName _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=True
End If
Range("L169").Select
ActiveWindow.SmallScroll Down:=-168
Application.WindowState = xlMinimized
End Sub
Thank you for your help!
Bookmarks