VBA excel export to PDF need to save in different location

lesleyfayburton

New Member
Joined
Dec 4, 2020
Messages
8
Office Version
  1. 2016
The following code is supposed to save the pdf in a different folder than where the current workbook with the data is being saved and I can't seem to fix the code to do that. I feel like it is something that I am not thinking of that is causing the issue. Thank you !

Sub Clickticketsaveemail1b1s()

Dim saveLocation As String
Dim rng As Range

saveLocation = "T:\Department\Investment Sales\_Restricted\TRADING\TRADE TICKETS"
Set rng = Sheets("Trade Ticket").Range("A1:G61")
FileName = Sheets("Trade Ticket").Range("R1").Value & ".pdf"

SaveAsStr = ActiveWorkbook.Path & "\" & Sheets("Trade Ticket").Range("R1").Value
rng.ExportAsFixedFormat Type:=xlTypePDF, FileName:=Sheets("Trade Ticket").Range("R1").Value & ".pdf", Quality:=xlQualityStandard, IncludeDocProperties:=False, IgnorePrintAreas:=False, OpenAfterPublish:=False

Dim xSht As Worksheet
Dim xFileDlg As FileDialog
Dim xFolder As String
Dim xYesorNo As Integer
Dim xOutlookObj As Object
Dim xEmailObj As Object
Dim xUsedRng As Range
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
How about
VBA Code:
saveLocation = "T:\Department\Investment Sales\_Restricted\TRADING\TRADE TICKETS"
Set rng = Sheets("Trade Ticket").Range("A1:G61")
Fname = Sheets("Trade Ticket").Range("R1").Value & ".pdf"

SaveAsStr = saveLocation & "\" & Fname
rng.ExportAsFixedFormat Type:=xlTypePDF, FileName:=SaveAsStr, Quality:=xlQualityStandard, IncludeDocProperties:=False, IgnorePrintAreas:=False, OpenAfterPublish:=False
 
Upvote 0
How about
VBA Code:
saveLocation = "T:\Department\Investment Sales\_Restricted\TRADING\TRADE TICKETS"
Set rng = Sheets("Trade Ticket").Range("A1:G61")
Fname = Sheets("Trade Ticket").Range("R1").Value & ".pdf"

SaveAsStr = saveLocation & "\" & Fname
rng.ExportAsFixedFormat Type:=xlTypePDF, FileName:=SaveAsStr, Quality:=xlQualityStandard, IncludeDocProperties:=False, IgnorePrintAreas:=False, OpenAfterPublish:=False
IT WORKED!!!! Oh my gosh thank you thank you
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,003
Messages
6,122,655
Members
449,091
Latest member
peppernaut

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