Print Worksheet Range to PDF on SharedDrive

reberryjr

Well-known Member
Joined
Mar 16, 2017
Messages
714
Office Version
  1. 365
Platform
  1. Windows
I'm trying to print a range from an worksheet to PDF. I'm using this code, but it takes minutes to run, and then it tells me the document didn't save. I've looked online and haven't seen anything that really guides me more than what I've been able to piece together from multiple posts I was able to find. What am I missing here?
VBA Code:
Sub PrintToPDF()

Application.ScreenUpdating = False
Application.DisplayAlerts = False

Dim m As Workbook
Dim mMS As Worksheet
Dim fPath, fName As String

Set m = ThisWorkbook
Set mMS = m.Sheets("MS1")

fPath = "\\crpcltnaf01n2\CRE Bankruptcy Loan\Statement Operations\BK Special Statement Application\Created Statements\"
fName = mMS.Range("K7").Value & ".pdf"

mMS.Range("A1:K264").ExportAsFixedFormat xlTypePDF, _
Filename:=fPath & fName, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False

Application.ScreenUpdating = True
Application.DisplayAlerts = True

End Sub
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

Forum statistics

Threads
1,224,828
Messages
6,181,217
Members
453,024
Latest member
Wingit77

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