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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
| Private Sub CommandButton16_Click()
'
' Edition des informations du bénévole
' Formulaire1 + compétences allouées + missions
' Création d'un fichier PDF
'
Dim h As Integer
Dim nom As String
Dim prenom As String
Dim nom_bencomp As String ' nom dans les données disque
Dim prenom_bencomp As String ' prénom dans les données disque
Dim code_bencomp As String
Dim partage_bencomp As String
Dim sNomPDF As String
Dim JobPDF As Variant
Dim ws4 As Variant
Dim libel_comp As String
nom = Me.TextBox1
prenom = Me.TextBox8
Dim np_conca As String
np_conca = nom & prenom
Dim nom_fichier As String
nom_fichier = np_conca
Dim Chemin As Variant
Chemin = chemin_1 & "gest_benevole\accords\benevole_ind\"
Set ws4 = Sheets("liste competences par personne")
' extraction des noms et prénom et codesdepuis classeur trié sur nom et prénom
'
ActiveWindow.SelectedSheets.HPageBreaks.Add before:=ActiveCell 'saut de page
libel_comp = " Compétences : code "
libel_comp = libel_comp & Chr(13) 'saut de ligne
For h = 2 To ws4.Range("A" & Rows.Count).End(xlUp).Row
code_bencomp = ws4.Range("B" & h).Value
nom_bencomp = ws4.Range("C" & h).Value
partage_bencomp = ws4.Range("E" & h).Value
prenom_bencomp = ws4.Range("D" & h).Value
If nom <> nom_bencomp Then GoTo selec_no
If prenom <> prenom_bencomp Then GoTo selec_no
libel_comp = libel_comp & code_bencomp & Chr(13)
selec_no: Next
Me.TextBox14 = libel_comp
Application.ScreenUpdating = False
PrintScreen
DoEvents
'
ThisWorkbook2.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.1) 'ancien 0,197
.HeaderMargin = Application.InchesToPoints(0)
.FooterMargin = Application.InchesToPoints(0)
.CenterHorizontally = True
.CenterVertically = True
.Orientation = xlPortrait
.Zoom = 70
End With
'passage en mode non partagé
' Mode SHARED "OFF" à l'ouverture
If ActiveWorkbook.MultiUserEditing Then
Application.DisplayAlerts = False ' Pas de message d'erreur
ActiveWorkbook.ExclusiveAccess ' Accès exclusif activé !
Application.DisplayAlerts = True
End If
ActiveSheet.PasteSpecial Format:="Bitmap", Link:=False, DisplayAsIcon:=False
Chemin = chemin_1 & "gest_benevole\rapports\benevole_ind\"
sNomPDF = Chemin & nom_fichier & Format(Date, "yyyymmdd") & "_" & Format(Time, "hhmmss") & ".pdf"
ActiveSheet.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=sNomPDF, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=False, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
' Application.DisplayAlerts = False
' Worksheets(Worksheets.Count).Delete
' Sauvegarde en réactivant le partage !
'If Not ActiveWorkbook.MultiUserEditing Then
'Application.DisplayAlerts = False
'ActiveWorkbook.SaveAs Filename:=ActiveWorkbook.FullName, accessMode:=xlShared
'Application.DisplayAlerts = True
'End If
' Unload Me
' Application.DisplayAlerts = True
' Application.ScreenUpdating = True
' Unload Me ' Vide et ferme l'Userform ( formulaire)
UserForm1.Show False
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