PDF file not appearing?

2022

Board Regular
Joined
Jun 5, 2022
Messages
74
Office Version
  1. 2016
Platform
  1. Windows
Hi, I've got some code which previously worked - ie creating a PDF of a worksheet, then saving the PDF file in the same folder as the worksheet.

However, it has stopped showing the PDF files that it creates.

Does anyone know why this would happen?

VBA Code:
Sub Save_PDF()

Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.Calculation = xlCalculationAutomatic

Dim wb As Workbook
Dim sh As Worksheet

Dim filename_user As Variant
Dim i As Long
Dim c As Long
Dim ShAr() As String

Set wb = ThisWorkbook
Set sh = wb.Sheets("ORIGINAL PAGE")


sh.PageSetup.PrintArea = "A1:M100"
sh.PageSetup.Orientation = xlPortrait


On Error GoTo Err
    'ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=ThisWorkbook.Path & "\" & Format(Now(), "yymmdd_hhnnss") & "_Auto Contract US Customer View"
    filename_user = VBA.InputBox("Enter the file name")
    '''Sheets(ShAr()).Select
    
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=ThisWorkbook.Path & "\" & filename_user
    
    MsgBox "Document saved as: " & vbCrLf & filename_user
    sh.Select
    sh.Range("A1").Select
    Application.ScreenUpdating = True
    Application.DisplayAlerts = True
    Application.Calculation = xlCalculationAutomatic
    Exit Sub
Err:
    MsgBox "Document not saved / Cancelled" & vbCrLf & _
    "Also, please close if the document is already opened and then try again."
    sh.Select
    sh.Range("A1").Select
    Application.ScreenUpdating = True
    Application.DisplayAlerts = True
    Application.Calculation = xlCalculationAutomatic
    Exit Sub
    
sh.Select
sh.Range("A1").Select
Application.ScreenUpdating = True
Application.DisplayAlerts = True
Application.Calculation = xlCalculationAutomatic
End Sub
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
I think the number of files in the folder I was saving it to were causing the issue!

Just tried to save the original file to a different directory, then re-created the PDF, and it appeared immediately!
 
Upvote 0

Forum statistics

Threads
1,214,784
Messages
6,121,535
Members
449,037
Latest member
tmmotairi

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