Hello,
I don't get why this code doesn't work, could someone help:
I don't get why this code doesn't work, could someone help:
Code:
Sub saveaspdf()
Dim TempFileName As String
'Prompt for file destination
With Application.FileDialog(msoFileDialogFolderPicker)
If .Show = True Then
DestFolder = .SelectedItems(1)
Else
MsgBox "You must specify a folder to save the PDF into." & vbCrLf & vbCrLf & "Press OK to exit this macro.", vbCritical, "Must Specify Destination Folder"
Exit Sub
End If
End With
Set wb1 = ActiveWorkbook
TempFileName = Replace(wb1.Name, ".xlsm", "") & " #" & Range("H5") & " " & Format(Now, "dd-mmm-yy")
'Create the PDF
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=TempFileName, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=OpenPDFAfterCreating
End Sub