1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| Private Sub CommandButton16_Click()
Dim sNomPDF As String
Application.ScreenUpdating = False
PrintScreen
DoEvents
MsgBox ThisWorkbook.Name
ThisWorkbook.Worksheets.Add After:=Worksheets(Worksheets.Count)
With ActiveSheet.PageSetup
.LeftMargin = Application.InchesToPoints(0.197)
.RightMargin = Application.InchesToPoints(0.197)
.TopMargin = Application.InchesToPoints(0.197)
.BottomMargin = Application.InchesToPoints(0.197)
.HeaderMargin = Application.InchesToPoints(0)
.FooterMargin = Application.InchesToPoints(0)
.CenterHorizontally = True
.CenterVertically = True
.Orientation = xlLandscape
End With
ActiveSheet.PasteSpecial Format:="Bitmap", Link:=False, DisplayAsIcon:=False
sNomPDF = ActiveWorkbook.Path & "\" & "UserForm.pdf"
ActiveSheet.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=sNomPDF, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=False, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
Application.DisplayAlerts = False
Worksheets(Worksheets.Count).Delete
Unload Me
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
Private Sub PrintScreen()
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
End Sub |
Partager