Is it possible to generate separate ranges onto the same pdf without Adobe Acrobat?

Mescoman

New Member
Joined
Oct 27, 2021
Messages
15
Office Version
  1. 365
Platform
  1. Windows
Hey hey people.

I was tasked with making a macro which combines two ranges into one pdf, one sheet for each range, and sends the single pdf to a list of emails. I have managed to get two seperate pdfs sent to the email list, but I am pretty stumped on how to combine the ranges. I initially came across some promising resources with Adobe Acrobat on this post Loop through files in folder that match part filename, but of course my computer doesnt have the software, and even if I were to get it, this Macro needs to work on many employees computers, so no cigar there. Perhaps if there were a way to get this software installed like a Reference? (this seems like a longshot to me)

My other idea was to copy the two ranges onto a new worksheet, "join them" together and just select the two ranges as one. This does work, but it absolutely messes up the formatting (merged cells, different column widths and row heights, different widths of ranges in general), so while this could work there may be a simpler way.

Does anyone have any suggestions as to what I could do? I can post my code if necessary but this seems more like a brainstorming sort of problem. Ill make sure to post my edited finished code if I manage to solve this particular part.

Many thanks and happy 2022!
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
VBA Code:
Sub Print_2Ranges()
     '2 ranges in the same sheet
     Range("A3:E7,A9:E30").ExportAsFixedFormat Type:=xlTypePDF, Filename:="C:\Data\Stal_Excell\Map1.pdf", OpenAfterPublish:=True

     '2 ranges in different sheets
     Sheets("blad1").PageSetup.PrintArea = "A1:D10"
     Sheets("blad2").PageSetup.PrintArea = "A3:F10"
     Sheets(Array("blad1", "blad2")).Select
     ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:="C:\Data\Stal_Excell\Map2.pdf", OpenAfterPublish:=True
End Sub
perhaps later add other stuff like zoom, margins, headers, etc
 
Upvote 0
Solution
Wow you can just place two ranges in the ".ExportAsFixedFormat" command, that is super simple. Thank you very much, it worked perfectly. If I could trouble you to help me with the zooms/margins Id appreciate it, though even if you dont your solution exactly solves my question.
 
Upvote 0
With 2 ranges on the same sheet, it's difficult to zoom, etc because you can make it perfect for just 1 range.
There is another feature, the camera. (see
i didn't look at that video, but i suppose it's educative)
You use that camera in another sheet, but with a screenshot to the 2nd range of your original sheet.

Then you export like the 2nd option in my post, 2 ranges in 2 different sheets.

In more complex situations, you can also be creative and use multiple cameras in the same sheet,
Make them all the same size and underneath each other with at least 1 free row in between.
When that is done, use method 1 "2 ranges on the same sheet)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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