The solutions comes in two parts. (It would be easier if Google
allowed upload, but perhaps it is a virus issue) Anyway, here is is i
plaintext. I hope you find it useful.
* The first is code that should be placed in a module in the VBA
editor (labeled [MODULE1.BAS] below)
* The second is a form, which you must create and place for controlls on:
form name "frmReplyAllEx"
textbox "txtName",
textbox "txtNumber",
button "cmdCancel",
button "cmdPreview"
(Place the code labeled [FRMREPLYALL.FRM] below in this form)
[MODULE1.BAS]
Option Explicit
Public Sub AddToToolBar()
Const NEW_BUTTON_CAPTION As String = "Reply to All Ex"
Const TOOLBAR_TO_USE As String = "Standard"
Dim oExplorer As Outlook.Explorer
Dim oCommandBars As CommandBars
Dim oCommandBar As CommandBar
Dim oButton As CommandBarControl
On Error GoTo Err
'Get the active explorer
Set oExplorer = Outlook.Application.ActiveExplorer
'Find the Standard toolbar
Set oCommandBars = oExplorer.CommandBars
Set oCommandBar = oCommandBars.Item(TOOLBAR_TO_USE)
On Error Resume Next
Set oButton = oCommandBar.Controls.Item(NEW_BUTTON_CAPTION)
If oButton Is Nothing Then
Set oButton = oCommandBar.Controls.Add(Type:=msoControlButton,
Temporary:=False)
End If
'Add a button
With oButton
.Caption = NEW_BUTTON_CAPTION
.Enabled = True
.HyperlinkType = msoCommandBarButtonHyperlinkOpen
.TooltipText = "Modified reply to all function"
.OnAction = "ReplyToAllEx"
End With
Exit Sub
Err:
MsgBox Err.Description, vbCritical
End Sub
Public Sub ReplyToAllEx()
Dim oExplorer As Outlook.Explorer
Dim oSelectedMail As MailItem
Dim oNewMail As MailItem
Dim sName As String
Dim sNumber As String
On Error GoTo Err
Set oExplorer = Outlook.Application.ActiveExplorer
'Check if something is selected
If oExplorer.Selection.Count > 0 Then
'Get the first item selected (currently only supports single selection)
Set oSelectedMail = ActiveExplorer.Selection.Item(1)
'Display the form
Set frmReplyAllEx = New frmReplyAllEx
frmReplyAllEx.Show
'Get the input from the form
sName = frmReplyAllEx.txtName
sNumber = frmReplyAllEx.txtNumber
'Check if a name was entered
If sName <> "" Then
'Create a Reply template
Set oNewMail = oSelectedMail.ReplyAll
With oNewMail
'Change the subject
.Subject = "RE: " & oSelectedMail.Subject & " [BKT/'"
& sNumber & "']"
'Change the body
.Body = "Hello '" & sName & "', " & " BKT/'" & sNumber & "'"
.Body = .Body & Chr(13) & Chr(13)
.Body = .Body & "Regards," & Chr(13)
.Body = .Body & Outlook.Application.Session.CurrentUser.Name
'Display the new mail before sending it
.Display
End With
End If
End If
Exit Sub
Err:
MsgBox Err.Description, vbCritical
End Sub
[FRMREPLYALL.FRM]
Option Explicit
Private Sub cmdCancel_Click()
txtName.Text = ""
txtNumber.Text = ""
Unload Me
End Sub
Private Sub cmdPreview_Click()
Me.Hide
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
txtName.Text = ""
txtNumber.Text = ""
End Sub |