Dim MailItem As Object
Dim Outlook As Object
Sub Exemple()
Application.Cursor = xlWait
ModelFile = "D:\...\...\...\Mail.docx"
' Test si la session Outlook est encore ouverte ------------
' (si on n'a pas fermé le mail suite à un Display précédent)
On Error Resume Next
Bidon = Outlook.ActiveWindow.WindowState
If Err = 0 Then MailItem.Close False: Outlook.Quit
' ----------------------------------------------------------
Err.Clear: On Error GoTo Exit_Error
Copy_Doc ModelFile
Set Outlook = CreateObject("Outlook.Application")
Set MailItem = Outlook.CreateItem(olMailItem)
With MailItem
.to = "??????@gmail.com"
.Subject = "Demandes de créneaux"
.Display
.GetInspector.wordeditor.Paragraphs(1).Range.Paste
End With
Exit_Error:
If Err Then
MsgBox "Erreur " & Err.Number & " - " & Err.Description & vbLf & _
"Recommencez ...", vbCritical + vbOKOnly
End If
Application.Cursor = xlDefault
End Sub
Sub Copy_Doc(Docname)
With CreateObject("Word.Application")
.Visible = False
.Documents.Open Docname, ReadOnly:=True
.ActiveDocument.Select
.Selection.Copy
.Quit
End With
End Sub