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
|
Sub test_lien_PDF() 'Devis
With ActiveSheet.PageSetup
.Orientation = xlLandscape
Worksheets("Demande de réparation").ExportAsFixedFormat Type:=xlTypePDF, _
Filename:="C:\Users\TECH\Desktop\enregistrement PDF.pdf", _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
.Orientation = xlLandscape
End With
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Dim olFormatHTML As String
FileAttach = "C:\Users\TECH\Desktop\enregistrement PDF.pdf" _
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
strbody = "Information sur la mise à jour"
On Error Resume Next
With OutMail
Select Case Sheets("Demande de réparation").Range("C3") ' <= la valeur à tester
case is ...
End Select
.Bcc = ""
.Subject = "Demande de réparation"
.HTMLBody = "Bonjour, <BR><BR>Ce message vous informe que " & Worksheets("Demande de réparation").Cells(3, "C") & " a enregistré la pièce " & Worksheets("Fiche de réparation").Cells(2, "I") & " dans le fichier réparation materiel .<BR><BR>" _
& "<A href=" & """" & "\\Nom_serveur\Repertoire\nom_ficihier.xls" & """" & "></A>" & Chr(10) & "<BR><BR>Cordialement"
.Attachments.Add Réparation_matériel_test2
.Attachments.Add (FileAttach)
.OriginatorDeliveryReportRequested = False
.ReadReceiptRequested = False
.Display
Dim SessionOutlook, myOlApp
Const Chemin As String = "C:\Program Files\Microsoft Office\Office12\OUTLOOK"
On Error Resume Next
Set Appli = GetObject(, "Outlook.Application")
If Appli Is Nothing Then
SessionOutlook = Shell(Chemin, 1)
Else
SessionOutlook = Shell(Chemin, 1)
End If
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Sub |