VBA code - Save file to folder within workbook path

floggingmolly

Board Regular
Joined
Sep 14, 2019
Messages
55
I have a code that creates a pdf and saves it in the folder where the workbook is saved. I have a sub folder PDF FILES. Is there a way to save to the PDF folder without using a full patch like c:\user\workbook\pdf files? Below is the code I have so far. Any help would be greatly appreciated.
Code:
FileName = ThisWorkbook.Path & "\" & .Range("F" & CustRow).Value & "_" & .Range("K" & CustRow).Value & ".pdf"
 

Some videos you may like

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
10,221
Office Version
2007
Platform
Windows
Something like this:

Code:
    [COLOR=#0000ff]sFolder[/COLOR] = Environ("userprofile") & "\workbook\pdf files\"
    FileName = [COLOR=#0000FF]sFolder[/COLOR] & .Range("F" & CustRow).Value & "_" & .Range("K" & CustRow).Value & ".pdf"
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=FileName, _
        Quality:=xlQualityStandard, IncludeDocProperties:=True, _
        IgnorePrintAreas:=False, OpenAfterPublish:=False
 

Watch MrExcel Video

Forum statistics

Threads
1,089,942
Messages
5,411,407
Members
403,368
Latest member
Cyril18

This Week's Hot Topics

Top