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
| Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Sub Creer_PDF_Demande_Prix()
Dim fichier As String, chemin As String, MyApdf As String
' Creer_PDF_Demande_Prix Macro
' il faut changer le chemin a chaque annee
'
'Condition si cellule E3 est egal a DEMANDE DE PRIX
If Range("E3") = "DEMANDE DE PRIX" Then
'Alors faire le PDF est l'enregistrer
chemin = "C:\_CIAM\13-DEMANDES DE PRIX\2013\"
fichier = chemin & [E4].Value & "-" & [H4].Value & "_" & [F6].Value & ".PDF"
ActiveSheet.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=fichier, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
Else 'Condition fausse renvoie le message Vous n'etes pas passé en Demande de prix
MsgBox "Vous n'etes pas passé en Commande"
End If
'Msg pour ouverture éventuelle du PDF
MyApdf = MsgBox("Do you want to open the PDF when done ?", vbYesNo, "Excel-Et-Vous")
If MyApdf = 6 Then
ShellExecute 0, "open", fichier, "", "", 1
End If
End Sub |