tech_droid
Member
- Outlook version
- Email Account
- Exchange Server
When it comes to VBA scripting and macro's, I avoid it like the plague. However I have a situation where an end user wants to always reply to people in HTML format. Regardless if it comes in as plain text or not. In any case, I was able to find the macro listed below that pretty much takes care of the users needs.
However... The additional problem that needs to be solved is that his signature which is HTML formatted is being inserted into the reply before the HTML formatting takes affect by the macro. So essentially the formatting gets wiped because it's being inserted into the email when it's still plain text and then gets the HTML macro hitting after the insert.
Is there a way to cause the macro to take affect before the signature is applied?
~~~~ Macro Being Used Below ~~~~
Option Explicit
Private WithEvents oExpl As Explorer
Private WithEvents oItem As MailItem
Private bDiscardEvents As Boolean
Private olFormat As OlBodyFormat
Private Sub Application_Startup()
Set oExpl = Application.ActiveExplorer
bDiscardEvents = False
'olFormat = olFormatPlain '(*1) - uz.ywaj zawsze formatu "zwyk?y tekst"
olFormat = olFormatHTML '(*2) - uz.ywaj zawsze formatu HTML
End Sub
Private Sub oExpl_SelectionChange()
On Error Resume Next
Set oItem = oExpl.Selection.Item(1)
End Sub
' (*3) Uz.ytkownik wybra? polecenie "Odpowiedz"
Private Sub oItem_Reply(ByVal Response As Object, Cancel As Boolean)
If bDiscardEvents Or oItem.BodyFormat = olFormat Then
Exit Sub
End If
'(*4) Anuluj domys'lna; akcje;
Cancel = True
bDiscardEvents = True
' (*5) Utwo'rz odpowiedz' na wiadomos'c' w formacie tekstowym
Dim oResponse As MailItem
Set oResponse = oItem.Reply
oResponse.Display
oResponse.BodyFormat = olFormat
bDiscardEvents = False
End Sub
' (*6) Uz.ytkownik wybra? polecenie "Odpowiedz wszystkim"
Private Sub oItem_ReplyAll(ByVal Response As Object, Cancel As Boolean)
If bDiscardEvents Or oItem.BodyFormat = olFormat Then
Exit Sub
End If
Cancel = True
bDiscardEvents = True
Dim oResponse As MailItem
Set oResponse = oItem.ReplyAll
oResponse.Display
oResponse.BodyFormat = olFormat
bDiscardEvents = False
End Sub
' (*7) Uz.ytkownik wybra? polecenie "Przes'lij dalej"
Private Sub oItem_Forward(ByVal Forward As Object, Cancel As Boolean)
If bDiscardEvents Or oItem.BodyFormat = olFormat Then
Exit Sub
End If
Cancel = True
bDiscardEvents = True
Dim oResponse As MailItem
Set oResponse = oItem.Forward
oResponse.Display
oResponse.BodyFormat = olFormat
bDiscardEvents = False
End Sub
However... The additional problem that needs to be solved is that his signature which is HTML formatted is being inserted into the reply before the HTML formatting takes affect by the macro. So essentially the formatting gets wiped because it's being inserted into the email when it's still plain text and then gets the HTML macro hitting after the insert.
Is there a way to cause the macro to take affect before the signature is applied?
~~~~ Macro Being Used Below ~~~~
Option Explicit
Private WithEvents oExpl As Explorer
Private WithEvents oItem As MailItem
Private bDiscardEvents As Boolean
Private olFormat As OlBodyFormat
Private Sub Application_Startup()
Set oExpl = Application.ActiveExplorer
bDiscardEvents = False
'olFormat = olFormatPlain '(*1) - uz.ywaj zawsze formatu "zwyk?y tekst"
olFormat = olFormatHTML '(*2) - uz.ywaj zawsze formatu HTML
End Sub
Private Sub oExpl_SelectionChange()
On Error Resume Next
Set oItem = oExpl.Selection.Item(1)
End Sub
' (*3) Uz.ytkownik wybra? polecenie "Odpowiedz"
Private Sub oItem_Reply(ByVal Response As Object, Cancel As Boolean)
If bDiscardEvents Or oItem.BodyFormat = olFormat Then
Exit Sub
End If
'(*4) Anuluj domys'lna; akcje;
Cancel = True
bDiscardEvents = True
' (*5) Utwo'rz odpowiedz' na wiadomos'c' w formacie tekstowym
Dim oResponse As MailItem
Set oResponse = oItem.Reply
oResponse.Display
oResponse.BodyFormat = olFormat
bDiscardEvents = False
End Sub
' (*6) Uz.ytkownik wybra? polecenie "Odpowiedz wszystkim"
Private Sub oItem_ReplyAll(ByVal Response As Object, Cancel As Boolean)
If bDiscardEvents Or oItem.BodyFormat = olFormat Then
Exit Sub
End If
Cancel = True
bDiscardEvents = True
Dim oResponse As MailItem
Set oResponse = oItem.ReplyAll
oResponse.Display
oResponse.BodyFormat = olFormat
bDiscardEvents = False
End Sub
' (*7) Uz.ytkownik wybra? polecenie "Przes'lij dalej"
Private Sub oItem_Forward(ByVal Forward As Object, Cancel As Boolean)
If bDiscardEvents Or oItem.BodyFormat = olFormat Then
Exit Sub
End If
Cancel = True
bDiscardEvents = True
Dim oResponse As MailItem
Set oResponse = oItem.Forward
oResponse.Display
oResponse.BodyFormat = olFormat
bDiscardEvents = False
End Sub