VBA code - Save file to folder within workbook path

floggingmolly

New Member
Joined
Sep 14, 2019
Messages
47
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"
 

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
7,835
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
 

Forum statistics

Threads
1,078,138
Messages
5,338,466
Members
399,234
Latest member
WaddoAU

Some videos you may like

This Week's Hot Topics

Top