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

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
56,614
Office Version
  1. 365
Platform
  1. Windows
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
 

lesleyfayburton

New Member
Joined
Dec 4, 2020
Messages
8
Office Version
  1. 2016
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
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
56,614
Office Version
  1. 365
Platform
  1. Windows
You're welcome & thanks for the feedback.
 

Watch MrExcel Video

Forum statistics

Threads
1,129,690
Messages
5,637,841
Members
416,985
Latest member
mrindira

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
Top