Saving Print Ranges

omagoodness

Board Regular
Joined
Apr 17, 2016
Messages
59
I have a named print range on a sheet ("TipsPaid") that I want to save to pdf using VBA and command button. The code I am using (below) will select the range and open in a pdf document but does not save it to a file. I have been over 4 hours trying to figue out why it will not save. What am I doing wrong? I'm sure it is something simple but I don't see it. Please help.
VBA Code:
Option Explicit
Private Sub cmdSave_Click()
'declaring variables

'Setting range to be saved
Dim PRng As Range
Set PRng = Range("TipsPaid")

'path to save folder
Dim myPath As String
myPath = Application.ThisWorkbook.Path & "\" & "Tip-out Records"

'setting file name
Dim SDate As String, filename As String
SDate = Application.WorksheetFunction.Text(Cells(3, 17), "dd mmm yyyy")
filename = "Week Ending" & " " & SDate & ".pdf"

'Save Location
 Dim SaveLocation As String
 SaveLocation = myPath & " \ " & filename
'Save as pdf
PRng.ExportAsFixedFormat Type:=xlTypePDF, filename:= _
             "SaveLocation", Quality:=xlQualityStandard, _
             IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True


End Sub
 
Thank you. I stuck that in at the bottom of my code and it saved a .pdf in the right folder but it was totally blank. I guess I just need to tweak a bit to include the range. I will ge tback to you on what happens. I have to be away from my computer for a while but I will get back to you. Thanks again.
Working perfectly. Thank you so much for all your help!
 
Upvote 0

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

Forum statistics

Threads
1,215,431
Messages
6,124,855
Members
449,194
Latest member
HellScout

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