Access Beginner
Active Member
- Joined
- Nov 8, 2010
- Messages
- 311
- Office Version
- 2016
- Platform
- Windows
Hello,
I've have code that creates a PDF from my workbook and this saves the PDF to a folder based on a cell (Menu Sheet A5). This cell is change via a drop down list, so I can change the location of where the PDF is saved to.
This issue I have, is someone has change the structure of our folders and the path is now a lot longer.
Path where it does work: Y:\ABC\FCIAIF\INDIGREM\Pndigeniis\Lusiness Puaaort ACoordiABCion\6. ABCIONAL PNDIGENIIS STRATEGIES\0. PNDIGENIIS MELVICING SPRATEGY (QWE)\
Path where it doesn't work: Y:\ABC\FCIAIF\INDIGREM\Pndigeniis\Lusiness Puaaort ACoordiABCion\6. ABCIONAL PNDIGENIIS STRATEGIES\0. PNDIGENIIS MELVICING SPRATEGY (QWE)\5. (QWE) REPORTING\2018 QWE DASHBOARD\Zone QWE Dashboards\Central HJN Badney\
Not to sure why this doesn't work, I initially thought it may have to do with a character limit in VBA or excel, but the character length of the longest path above is 216.
Any ideas?
I've have code that creates a PDF from my workbook and this saves the PDF to a folder based on a cell (Menu Sheet A5). This cell is change via a drop down list, so I can change the location of where the PDF is saved to.
This issue I have, is someone has change the structure of our folders and the path is now a lot longer.
Path where it does work: Y:\ABC\FCIAIF\INDIGREM\Pndigeniis\Lusiness Puaaort ACoordiABCion\6. ABCIONAL PNDIGENIIS STRATEGIES\0. PNDIGENIIS MELVICING SPRATEGY (QWE)\
Path where it doesn't work: Y:\ABC\FCIAIF\INDIGREM\Pndigeniis\Lusiness Puaaort ACoordiABCion\6. ABCIONAL PNDIGENIIS STRATEGIES\0. PNDIGENIIS MELVICING SPRATEGY (QWE)\5. (QWE) REPORTING\2018 QWE DASHBOARD\Zone QWE Dashboards\Central HJN Badney\
Not to sure why this doesn't work, I initially thought it may have to do with a character limit in VBA or excel, but the character length of the longest path above is 216.
Any ideas?
Code:
Sub PDFPrint()
Dim ReportPath As Variant
Dim ReportName As Variant
Dim ToPrint As Variant
Set ReportPath = Sheets("Menu").Range("A5")
Set ReportName = Sheets("Menu").Range("A3")
Set ToPrint = Sheets("Menu").Range("A4")
Worksheets("ISS_Charts").Activate
On Error Resume Next
With ActiveSheet
.PageSetup.PrintArea = ToPrint
.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=ReportPath & ReportName & ".PDF", _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=True
On Error Resume Next
End With
MsgBox " PDF document:" & vbCrLf & "File Name: " _
& ReportName & vbCrLf & vbCrLf & " Has been created and has been saved to:" _
& vbCrLf & vbCrLf & "File Location: " & ReportPath
End Sub