Luke,
Attached is a modified version of your posted workbook.
The green shape has had its text changed to "Save both pdf and xlsm"
It has been assigned to the following macro:
Sub tgr_SaveBoth_PDF_and_XLSM()
Call SaveFile(Range("K10").Text & Range("F4").Text & ".xlsm", ActiveSheet)
Call SaveFile(Range("K11").Text & Range("F4").Text & ".pdf", ActiveSheet)
End Sub
The orange shape has had its text changed to "Save xlsm"
It has been assigned to the following macro:
Sub tgr_SaveXLSM()
Call SaveFile(Range("K12").Text & Range("F4").Text & ".xlsm", ActiveSheet)
End Sub
The black shape has had its text changed to "Save as dialog"
It has been assigned to the following macro:
Sub tgr_SaveAs_xlsm()
Dim strSave As String
strSave = Application.GetSaveAsFilename(Range("F4").Text, "Excel Macro Enabled Workbook, *.xlsm")
If strSave = "False" Then Exit Sub 'Pressed cancel
Call SaveFile(strSave, .ActiveSheet)
End Sub
All three of those macros call the following macro named SaveFile:
Public Sub SaveFile(ByVal strFullPath As String, ByRef ws As Worksheet)
Dim strExt As String
strExt = Mid(strFullPath, InStrRev(strFullPath, "."))
On Error GoTo CleanExit
Select Case strExt
Case ".xlsm": ActiveWorkbook.SaveAs strFullPath, xlOpenXMLWorkbookMacroEnabled
Case ".pdf": ws.ExportAsFixedFormat xlTypePDF, strFullPath
Case Else: MsgBox "Invalid File format." & vbCrLf & "Must be .xlsm or .pdf", , "Invalid Format"
End Select
Exit Sub
CleanExit:
MsgBox "Save operation failed" & vbCrLf & "File path not found: " & Left(strFullPath, InStrRev(strFullPath, Application.PathSeparator)), , "Save Error"
Err.Clear
End Sub
Bookmarks