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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
| Option Explicit
Sub createNewSignature()
'---------------------------------------------------------------------------------------
' Procedure : createNewSignature
' Author : Oliv-
' Date : 26/06/2018
' Purpose : création de signature pour OUTLOOK 2010
'---------------------------------------------------------------------------------------
'
Dim objNS As Object
Dim objMsg As Outlook.MailItem
Dim objDoc As Word.Document
Dim objSel As Word.Selection
Dim objSig As Word.EmailSignature
Dim colSig As Word.EmailSignatureEntries
Dim NewSig As Word.EmailSignatureEntry
Dim objInsp As Outlook.Inspector
Dim MonImage As Object
Dim Nom_Signature As String
Const olmailitem = 0
Const wdCollapseEnd = 0
Const wdStory = 6
Const olDiscard = 1
Const olMinimized = 1
Dim Fonction, Fax, FirstName, LastName, CompanyName, StreetAddress, City, PostalCode, Alias, BusinessTelephoneNumber, MobileTelephoneNumber, PrimarySmtpAddress
Dim OL As Outlook.Application
If UCase(Application) = "OUTLOOK" Then
Set OL = Application
Else
Set OL = CreateObject("outlook.application")
End If
Set objNS = OL.Session
Nom_Signature = "TEST"
FirstName = InputBox("Prénom", "Création de signature")
LastName = InputBox("Nom", "Création de signature")
CompanyName = InputBox("Société", "Création de signature")
StreetAddress = InputBox("Adresse", "Création de signature")
City = InputBox("Ville", "Création de signature")
PostalCode = InputBox("Code Postal", "Création de signature")
'Alias = .Alias
BusinessTelephoneNumber = InputBox("Avez-vous une Téléphone Direct ?", "Création de signature", "+ 33 0 00 00 00 00")
MobileTelephoneNumber = InputBox("Avez-vous une Téléphone Mobile ?", "Création de signature", "+ 33 6 00 00 00 00")
PrimarySmtpAddress = InputBox("Email", "Création de signature")
Fonction = InputBox(FirstName & " " & LastName & vbCr & " Quelle est votre FONCTION ?", "Création de la signature", "exemple")
'création Email préparer la signature
Set objMsg = objNS.Application.CreateItem(olmailitem)
objMsg.Display
objMsg.Body = ""
Set objInsp = objMsg.GetInspector
'objInsp.WindowState = olMinimized
Set objDoc = objInsp.WordEditor
' On Error Resume Next
objDoc.Paragraphs(objDoc.Paragraphs.Count).Range.Select
With objDoc.Application.Selection
.Font.Name = "Arial"
.Font.Size = 9
.Font.Bold = True
.TypeText Text:=FirstName & ", " & LastName
.TypeParagraph
.Font.Bold = False
.TypeText Text:=Fonction
.TypeParagraph
.TypeParagraph
.Font.Bold = True
.TypeText Text:=CompanyName
.Font.Bold = False
.TypeParagraph
.TypeText Text:=StreetAddress & " | adresse 2" & " | " & PostalCode & " " & City
.TypeParagraph
.TypeText Text:="France"
.TypeParagraph
.TypeParagraph
If BusinessTelephoneNumber <> "+ 33 0 00 00 00 00" And BusinessTelephoneNumber <> "" Then
.TypeText Text:="D " & BusinessTelephoneNumber
.TypeParagraph
End If
If MobileTelephoneNumber <> "+ 33 6 00 00 00 00" And MobileTelephoneNumber <> "" Then
.TypeText Text:="M " & MobileTelephoneNumber
.TypeParagraph
End If
.Hyperlinks.Add Anchor:=.Range, Address:= _
"mailto:" & PrimarySmtpAddress, SubAddress:="", ScreenTip:="", _
TextToDisplay:=PrimarySmtpAddress
.TypeParagraph
End With
objDoc.Paragraphs(objDoc.Paragraphs.Count).Range.Select
Set objSig = objDoc.Application.EmailOptions.EmailSignature
Set colSig = objSig.EmailSignatureEntries
objDoc.Range(0, 0).Select
objDoc.Application.Selection.MoveEnd wdStory
DoEvents
'AJOUT DE LA SIGNATURE AVEC IMAGE
objDoc.Paragraphs(objDoc.Paragraphs.Count).Range.Select
Set MonImage = objDoc.Application.Selection.InlineShapes.AddPicture(Filename:= _
"O:\temp\Bandeau_Signature.png", LinkToFile:= _
True, SaveWithDocument:=False)
objDoc.Hyperlinks.Add Anchor:=MonImage.Range, Address:= _
"http://www.ste.com" _
, SubAddress:=""
objDoc.Range(0, 0).Select
objDoc.Application.Selection.MoveEnd wdStory
Set objSel = objDoc.Application.Selection
Set NewSig = colSig.Add(Nom_Signature, objSel.Range)
objInsp.Close olDiscard
DoEvents
'POUR DEFINIR les signatures par defaut
objSig.NewMessageSignature = Nom_Signature
objSig.ReplyMessageSignature = Nom_Signature
Set objMsg = Nothing
Set objInsp = Nothing
Set objDoc = Nothing
Set objSel = Nothing
Set colSig = Nothing
Set objSig = Nothing
End Sub |
Partager