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 EnvoiPigna()
Dim wApp As Word.Application
Dim oDoc As Word.Document
Dim oDoc2 As Word.Document
Dim path As String, brief As String, Dokuliste As String
path = ActiveWorkbook.ActiveSheet.Range("b7")
brief = ActiveWorkbook.ActiveSheet.Range("c7")
Dokuliste = ActiveWorkbook.ActiveSheet.Range("H7")
création du courrier à envoyer avec les catalogues
'Affectation des données aux variables
Set wApp = New Word.Application
Set oDoc = wApp.Documents.Add(path & brief)
'Affectation des données Excel aux signets
oDoc.Bookmarks("Nom").Range.Text = ActiveWorkbook.ActiveSheet.Range("b2")
'Rendre Word Visible
wApp.Visible = True
oDoc.SaveAs ("K:\xxxx_INTERN\Dokuversand_Pigna\2018\" & "Brief" & ActiveWorkbook.ActiveSheet.Range("c2").Value & " - " & ActiveWorkbook.ActiveSheet.Range("d2").Value & " - " & ActiveWorkbook.ActiveSheet.Range("b2").Value & ".docx")
oDoc.Close
Set oDoc = Nothing
création de la liste des catalogues à envoyer
Set oDoc2 = wApp.Documents.Add(path & Dokuliste)
'Affectation des données Excel aux signets
oDoc2.Bookmarks("H").Range.Text = ActiveWorkbook.ActiveSheet.Range("H2")
oDoc2.Bookmarks("AJ").Range.Text = ActiveWorkbook.ActiveSheet.Range("AJ2")
'Rendre Word Visible
wApp.Visible = True
oDoc2.SaveAs ("K:\ xxxx_INTERN\Dokuversand_Pigna\2018\Broschueren " & ActiveWorkbook.ActiveSheet.Range("c2").Value & " - " & ActiveWorkbook.ActiveSheet.Range("d2").Value & " - " & ActiveWorkbook.ActiveSheet.Range("b2").Value & ".docx")
wApp.Quit
ThisWorkbook.Worksheets("Pigna").Activate
ActiveWorkbook.ActiveSheet.Range("ZahlDoku").Value = ""
Envoi par email du courrier et de la liste à limprimerie
Dim myApp2 As Object, myitem2 As Object, signature2 As String, brief2 As String, Doku2 As String
brief2 = "K:\ xxxx_INTERN\Dokuversand_Pigna\2018\" & "Brief" & ActiveWorkbook.ActiveSheet.Range("c2").Value & " - " & ActiveWorkbook.ActiveSheet.Range("d2").Value & " - " & ActiveWorkbook.ActiveSheet.Range("b2").Value & ".docx"
Doku2 = "K:\ xxxx_INTERN\Dokuversand_Pigna\2018\Broschueren " & ActiveWorkbook.ActiveSheet.Range("c2").Value & " - " & ActiveWorkbook.ActiveSheet.Range("d2").Value & " - " & ActiveWorkbook.ActiveSheet.Range("b2").Value & ".docx"
Set myApp2 = CreateObject("Outlook.Application")
Set myitem2 = myApp2.CreateItem(olMailItem)
With myitem2
myitem2.Subject = ActiveWorkbook.ActiveSheet.Range("C2") & " " & ActiveWorkbook.ActiveSheet.Range("d2") & "- Merci denvoyer les catalogues "
myitem2.body = "Cordialement, " & _
"Laure ."
myitem2.Attachments.Add brief2
myitem2.Attachments.Add Doku2
myitem2.to = "xxx.xx@pigna.ch; <a href="mailto:xxx-pigna@bluewin.ch">xxx-pigna@bluewin.ch</a>"
myitem2.display
End With
End Sub |
Partager