Create button to Save specific page ranges from each worksheet in the workbook

projectatpel

New Member
Joined
Oct 18, 2013
Messages
11
I have an excel workbook containing about 4 worksheets.
The second worksheet has all the inputs I give and the outputs that I require.
The fourth worksheet has graphs.
All the calculations happen on other worksheets
I need to create a command button, which when clicked saves a certain pages of each worksheet as a PDF file.
Say, I need the the 1st page of Worksheet 1, 1st page of Worksheet 2 and 1st and 2nd pages of Worksheet 4
(all pages laid-out as A4 using "Page layout > Size > A4 "and viewed as "View > Page Layout")
Is it possible to get a VB code to save those particular pages as a single PDF document.
Also the PDF document must derive its file name from two different cells in Worksheet 1
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
I tried a code which is as follows, but it doesn't seem to work.
If anyone could check the error

Code:
Sub Save()
'
' 
Dim fName As String, fPath As String
Dim part1 As String


part1 = Range("D5").Value
fPath = "D:\Test\"
fName = "part1_" & Format(Date, "dd-mmm-yyyy \at  hh:mm:ss AM/PM")


    Sheets(Array("asd", "Graphs")).Select
      Sheets("asd").Activate
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
        "fPath & fName.pdf", _
        Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
        :=True, OpenAfterPublish:=True


    Sheets("asd").Select
End Sub
 
Upvote 0

Forum statistics

Threads
1,216,069
Messages
6,128,599
Members
449,460
Latest member
jgharbawi

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