Hoping someone can help me. I have most of the coding worked out but i cannot get it to agree to save with the custom file name.
I have two different pages which display data slightly differently depending on the user need. The result should be that they pick which report they want to generate as a PDF and then the save option comes up with the filename generated and the correct folder selected. Currently the only part that does not happen is the filename. I have attached the code below:
Sub PDF_EOD()
Dim Result As Integer
Dim Opendialog As Variant
Result = MsgBox("Was the Function Bar banking included in todays figures?", vbQuestion + vbYesNo)
If Result = vbYes Then
'''''
Sheets("EOD Banking Sheet 1").Select
Opendialog = Application.GetSaveAsFilename(Sheet1.[A10].Value, "PDF (*.pdf), *.pdf")
If Not Opendialog <> False Then MsgBox "File not saved.", vbCritical: Exit Sub
Dim fName As String
fName = "EOD" & Format(Date, "yyyymmdd")
ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"Z:\EOD Reports" & fName, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
MsgBox "Saved.", vbInformation
Sheets("Main").Select
Else
Sheets("EOD Banking Sheet 2").Select
Opendialog = Application.GetSaveAsFilename(Sheet1.[A10].Value, "PDF (*.pdf), *.pdf")
If Not Opendialog <> False Then MsgBox "File not saved.", vbCritical: Exit Sub
ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"Z:\EOD Reports" & fName, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
MsgBox "Saved.", vbInformation
Sheets("Main").Select
End If
End Sub
I have two different pages which display data slightly differently depending on the user need. The result should be that they pick which report they want to generate as a PDF and then the save option comes up with the filename generated and the correct folder selected. Currently the only part that does not happen is the filename. I have attached the code below:
Sub PDF_EOD()
Dim Result As Integer
Dim Opendialog As Variant
Result = MsgBox("Was the Function Bar banking included in todays figures?", vbQuestion + vbYesNo)
If Result = vbYes Then
'''''
Sheets("EOD Banking Sheet 1").Select
Opendialog = Application.GetSaveAsFilename(Sheet1.[A10].Value, "PDF (*.pdf), *.pdf")
If Not Opendialog <> False Then MsgBox "File not saved.", vbCritical: Exit Sub
Dim fName As String
fName = "EOD" & Format(Date, "yyyymmdd")
ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"Z:\EOD Reports" & fName, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
MsgBox "Saved.", vbInformation
Sheets("Main").Select
Else
Sheets("EOD Banking Sheet 2").Select
Opendialog = Application.GetSaveAsFilename(Sheet1.[A10].Value, "PDF (*.pdf), *.pdf")
If Not Opendialog <> False Then MsgBox "File not saved.", vbCritical: Exit Sub
ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"Z:\EOD Reports" & fName, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
MsgBox "Saved.", vbInformation
Sheets("Main").Select
End If
End Sub