VBA export to PDF very slow

Shadkng

Active Member
Joined
Oct 11, 2018
Messages
370
The below code used to export to PDF saves fast on one computer and very slow on another similar computer. On the slow computer I use Foxit and not Adobe. Does that matter? Do I have to have Foxit as an add-on in excel? If I save the file manually using the menu and save as it seems to work fine. Any help would be appreciated.

Sub DETAIL_PDF()
Dim response As String
Dim PrintAreaString As String
response = InputBox("Enter column letter for 2nd part of range", "Enter Data")
Application.ScreenUpdating = False
With ActiveSheet
PrintAreaString = "$A$3:$" & Trim(UCase(response)) & "$" & .Range("B1").Value
If response <> "" Then
.PageSetup.PrintArea = PrintAreaString
.PageSetup.Orientation = xlLandscape
.PageSetup.Zoom = False
.PageSetup.FitToPagesWide = 1
.PageSetup.FitToPagesTall = False
.PageSetup.LeftMargin = 36
.PageSetup.TopMargin = 72
.PageSetup.RightMargin = 36
.PageSetup.BottomMargin = 36
End If
End With
ChDir ActiveWorkbook.Path & ""
fileSaveName = "FRIEDLAND QUOTE " & Range("B6").Value & " " & "JOB " & Range("B7").Value & " " & Range("A15").Value & " " & Range("B15").Value & " " & Range("AB15").Value & " " & Range("AD15").Value & Range("B9").Value & " PCS" & " " & Format(Date, "mmddyy")
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
fileSaveName _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=True '(change this to "False" to prevent the file from opening after saving)
Application.ScreenUpdating = True
End Sub
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
I don't see anything you could change that would speed it up. I would run an anti-virus and CCleaner.exe to clean up temp files.

Things to tidy up:
1. $ and case in printareastring won't mean anything.
Code:
PringAreaString = "A3:" & response & [B1]

2. I don't use ChDir, I just concatenate the path. e.g.
Code:
fileSaveName = ActiveWorkbook.Path & "\" & "FRIEDLAND QUOTE " & [B6] " " & "JOB " & [B7] & " " & [A15] & " " & [B15' & " " & _
[AB15] & " " & [AD15] & [B9] & " PCS" & " " & Format(Date, "mmddyy")
 
Upvote 0
I used your code in #2 and it works fine and I see it's a lot cleaner. As far as the slowness, I'm just wondering if it's a setting in my excel. Does excel require any software to export to PDF, such as adobe? Or an add-in?
 
Upvote 0
I found the problem which had nothing to do with excel...my default printer was the culprit although not sure why. So I switched the default and it works fine. Thanks
 
Upvote 0
One can set a default printer and switch back but you need to know the printer name to switch to.

If a one off deal, your manual change should suffice.
 
Upvote 0

Forum statistics

Threads
1,223,996
Messages
6,175,851
Members
452,675
Latest member
duongtruc1610

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