Reputation: 33
I received a request from one of my users to create a macro in Outlook.
His requirements were to have an email header that is bold, highlighted and in italics.
This part we were able to accomplish, but he has also requested that the cursor end up in the body of the email just below the header ready to input text using his regular formatting options (font, size, color).
Currently when our macro runs, the cursor ends up at the beginning of the email header.
If you move the cursor to the line below the header then the text is still bold and italicized.
Is there a way to reset the text formatting after the header is inserted, and is there a way to specify that the cursor end up below the header? This is what we have come up with so far:
Sub Testmacro2()
Dim olApp As Outlook.Application, olEmail As Outlook.MailItem, signature As String
Set olApp = CreateObject("Outlook.Application")
Set olEmail = olApp.CreateItem(0)
With olEmail
.Display
End With
signature = olEmail.HTMLBody
With olEmail
.HTMLBody = "<HTML><BODY><span style='background:yellow;mso-highlight:yellow'><em><b><p style=font-size:14pt>Privileged & Confidential Attorney Client Communication & Work Product.</b></em><br></span></BODY></HTML>" & vbNewLine & signature
End With
Set olEmail = Nothing
Set olApp = Nothing
End Sub
Upvotes: 3
Views: 993
Reputation: 66341
You will need to work with Inspector.WordEditor
(returns an instance of the Word.Document
object), namely Inspector.WordEditor.Application.Selection
.
Inspector object can be retrieved from MailItem.GetInspector
.
Upvotes: 0