The clipboard to BMP API's used in userform1 has a problem. It has a DLL entry point error for the SetClipboardData. Since routines need to return LongPtr type, there is no point in using the VBA7 test. I attached the file in case someone has time to debug it. If you do test it and it errors, simply close Excel and reopen to fix the clipboard memory overload.
For me, the API sendkeys method seems to "work". I made it into a Function for you. Put this into a new Module. No check was made to see if the drive and path for the pdf filename is valid/exists.
'Similar to jaslake,https://www.excelforum.com/excel-programming-vba-macros/1202015-print-userform-to-pdf-and-then-attach-it-to-an-email.html
#If VBA7 Then
Declare PtrSafe Sub keybd_event Lib "user32" (ByVal bVk As Byte, _
ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As LongPtr)
#Else
Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, _
ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
#End If
Private Const VK_SNAPSHOT = 44
Private Const VK_LMENU = 164
Private Const KEYEVENTF_KEYUP = 2
Private Const KEYEVENTF_EXTENDEDKEY = 1
Function WindowToPDF(pdf$, Optional Orientation As Integer = xlLandscape, _
Optional FitToPagesWide As Integer = 1) As Boolean
Dim calc As Integer, ws As Worksheet
With Application
.ScreenUpdating = False
.EnableEvents = False
calc = .Calculation
.Calculation = xlCalculationManual
End With
DoEvents
keybd_event VK_LMENU, 0, KEYEVENTF_EXTENDEDKEY, 0
keybd_event VK_SNAPSHOT, 0, KEYEVENTF_EXTENDEDKEY, 0
keybd_event VK_SNAPSHOT, 0, KEYEVENTF_EXTENDEDKEY + KEYEVENTF_KEYUP, 0
keybd_event VK_LMENU, 0, KEYEVENTF_EXTENDEDKEY + KEYEVENTF_KEYUP, 0
DoEvents
Set ws = Workbooks.Add(xlWBATWorksheet).Worksheets(1)
With ws
.PasteSpecial Format:="Bitmap", Link:=False, DisplayAsIcon:=False
.Range("A1").Select
.PageSetup.Orientation = Orientation
.PageSetup.FitToPagesWide = FitToPagesWide
.PageSetup.Zoom = False
.ExportAsFixedFormat Type:=xlTypePDF, Filename:=pdf, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, _
IgnorePrintAreas:=False, OpenAfterPublish:=False
.Parent.Close False
End With
With Application
.ScreenUpdating = True
.EnableEvents = True
.Calculation = calc
.CutCopyMode = False
End With
WindowToPDF = Dir(pdf) <> ""
End Function