Advertisement
Guest User

Untitled

a guest
Mar 30th, 2020
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 2.30 KB | None | 0 0
  1. Sub EnvoiMailConso()
  2.  
  3. Dim rng As Range
  4. Dim OutApp As Object
  5. Dim OutMail As Object
  6.  
  7. Set rng = Nothing
  8.  
  9. ' tableau variations
  10. With Sheets("BDL retraité")
  11.    
  12.     Set rng = .Range("D1:M8")
  13.  
  14. End With
  15.  
  16. rng.CopyPicture
  17.  
  18. If rng Is Nothing Then
  19.     MsgBox "The selection is not a range or the sheet is protected. " & _
  20.            vbNewLine & "Please correct and try again.", vbOKOnly
  21.     Exit Sub
  22. End If
  23.  
  24. With Application
  25.     .EnableEvents = False
  26.     .ScreenUpdating = False
  27. End With
  28.  
  29. Set OutApp = CreateObject("Outlook.Application")
  30. Set OutMail = OutApp.CreateItem(0)
  31.  
  32.  
  33. With OutMail
  34.     .To = "christophe.marle@savilecapital.lu"
  35.     .CC = "pe.pourrat@savilecapital.lu;jacques.bossuyt@savilecapital.lu"
  36.     .BCC = "christian.mouisel@savilecapital.lu"
  37.     ' SUJET DU MAIL, MODIFIER LA DATE DANS Range("E9")
  38.     .Subject = "SOI au " & Sheets("BDL retraité").Range("E9")
  39. '    .HTMLBody = RangetoHTML(rng)
  40.     ' In place of the following statement, you can use ".Display" to
  41.     ' display the e-mail message.
  42.     .Display
  43. End With
  44. On Error GoTo 0
  45.  
  46. 'Get its Word editor
  47. Dim wordDoc As Word.Document
  48. Set wordDoc = OutMail.GetInspector.WordEditor
  49.  
  50. 'Colle tableau variations
  51. wordDoc.Range.PasteAndFormat wdChartPicture
  52. wordDoc.Range.InsertParagraphAfter
  53.  
  54. 'Graphique Allocations
  55. Sheets("BDL retraité").ChartObjects("Graphique 7").Copy
  56. With wordDoc.Range(wordDoc.Characters.Count - 1, wordDoc.Characters.Count)
  57.     .InsertAfter Chr(11) & Chr(11)
  58. End With
  59. wordDoc.Range(wordDoc.Characters.Count - 1, wordDoc.Characters.Count).PasteAndFormat wdChartPicture
  60.  
  61. 'Graphique Devises
  62. Sheets("BDL retraité").ChartObjects("Graphique 6").Copy
  63. With wordDoc.Range(wordDoc.Characters.Count - 1, wordDoc.Characters.Count)
  64.     .InsertAfter Chr(11) & Chr(11)
  65. End With
  66. wordDoc.Range(wordDoc.Characters.Count - 1, wordDoc.Characters.Count).PasteAndFormat wdChartPicture
  67.  
  68. 'Graphique Contribution par masses
  69. Sheets("BDL retraité").Range("D77:F86").Copy
  70. With wordDoc.Range(wordDoc.Characters.Count - 1, wordDoc.Characters.Count)
  71.     .InsertAfter Chr(11) & Chr(11)
  72. End With
  73. wordDoc.Range(wordDoc.Characters.Count - 1, wordDoc.Characters.Count).PasteAndFormat wdChartPicture
  74.  
  75.  
  76. With Application
  77.     .EnableEvents = True
  78.     .ScreenUpdating = True
  79. End With
  80.  
  81. Set OutMail = Nothing
  82. Set OutApp = Nothing
  83. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement