Updating Macro to OL2010/32bit

Status
Not open for further replies.

benjaminearle

Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
Hello,

I was forced to get a new OS (Win7/32) and new Outlook (2010 32bit) after my hard drive started threatening a catastrophic failure (click click beep beep beep).

I had a nifty macro in my old outlook that i re-installed in my new but it is not functioning completely.

For background, the only factory settings I have changed in OL are to attach an original when replying, replying to all or forwarding (to preserve attachments). I have enabled macros.

The macro should (did in Outlook 2003 and 2007):
1. Delete the original when replying, replying all, forwarding
2. Force a folder choice upon send

Item #2 is working, so I know the macro is at least trying to run. I assume some portion of the code just needs some 2010-style massaging. Any help would be greatly appreciated. This little tool has helped me keep my inbox under 100 items for years now. Very helpful since my inbox truncates, irretrievably at 30d age.

Macro:

' </DeleteOriginalWhenReply
Option Explicit

Private WithEvents ReplyButton As Office.CommandBarButton

Private WithEvents ForwardButton As Office.CommandBarButton

Private WithEvents ReplyAllButton As Office.CommandBarButton

Private WithEvents m_Inspectors As Outlook.Inspectors

Private m_Mail As Outlook.MailItem

Private Sub Application_Startup()
Set ReplyButton = Application.ActiveExplorer.CommandBars.FindControl(, 354)
Set ForwardButton = Application.ActiveExplorer.CommandBars.FindControl(, 356)
Set ReplyAllButton = Application.ActiveExplorer.CommandBars.FindControl(, 355)
Set m_Inspectors = Application.Inspectors

End Sub

Private Sub m_Inspectors_NewInspector(ByVal Inspector As Outlook.Inspector)
On Error Resume Next
If Not m_Mail Is Nothing Then
m_Mail.Delete
Set m_Mail = Nothing
End If

End Sub

Private Sub ReplyButton_Click(ByVal Ctrl As Office.CommandBarButton, _
CancelDefault As Boolean _

)
On Error Resume Next
If TypeOf Application.ActiveWindow Is Outlook.Explorer Then
Set m_Mail = Application.ActiveExplorer.Selection(1)
Else
Set m_Mail = Application.ActiveInspector.CurrentItem
End If

End Sub

' </DeleteOriginalWhenReply
' </Assign Folder for Sent Messages
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
If TypeOf Item Is Outlook.MailItem Then
Cancel = Not SaveSentMail(Item)
End If

End Sub

Private Function SaveSentMail(Item As Outlook.MailItem) As Boolean
Dim F As Outlook.MAPIFolder
If Item.DeleteAfterSubmit = False Then
Set F = Application.Session.PickFolder
If Not F Is Nothing Then
Set Item.SaveSentMessageFolder = F
SaveSentMail = True
End If
End If

End Function

' </Assign Folder for Sent Messages
Many many thanks and I hope once repaired this code can be useful to others as well. Both of these actions seem like things that could be factory-integrated into Outlook to reduce inbox size.

-Ben
 
It should work in 2010 too. Put in some breakpoints and see if it hits them.

It's working in 2013 - even with inline compose (reading pane compose) and a lot of stuff won't work with it.

I'll fall on my pride sword here - breakpoints? I didn't write that original macro in it's entirety. It was originally only used for "reply" and i added "reply-all" and "forward". So, it was largely copy/paste (i'm good at that).

I'll do some searching for the breakpoint bit but if I don't post an update, i'd sure like some help.

Also, I have it all in one Project - VbaProject.OTM - ThisOutlookSession (Code) under Project1 just like i did in 2007. Did I need to split it up?

MacroWindow.jpg

-Ben
 
It should work in 2010 too. Put in some breakpoints and see if it hits them.

It's working in 2013 - even with inline compose (reading pane compose) and a lot of stuff won't work with it.

OK, so i figured out the breakpoint thing (that's cool).

it appears to be skipping over these two lines:
m_Mail.Delete
Set m_Mail = Nothing

they have little breakpoint buttons next to them but it hops from
If Not m_Mail Is Nothing Then

to
End If

And, the mail remains undeleted.
 
I goofed when I tested it - it was not working in Outlook 2013. I dropped a note to the guy who owns the site where I presume you got the macro from (he has one like it posted in his collection) - it looks like it should work but he'll know if there is something changed in outlook 2010 that would affect it. He's in Germany, so it might be tomorrow before I hear back.
 
Michael said its because command bars aren't supported in 2010 and he's going to update his page tomorrow. (I think what he means is the inspector cant identify the message because of changes to the command bar support.)

the original code VBOffice - Samples
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
P Updating Last Modified Date on ThisOutlookSession Macro Outlook VBA and Custom Forms 1
M Outlook 2016 still feature updating Using Outlook 0
P Outlook tasks keeps changing (updating) dates that I type Using Outlook 2
I Outlook is stuck at "Updating Calendar" Using Outlook 1
A VBscript stops running after updating form Outlook VBA and Custom Forms 1
D Custom Search Folders not refreshing/updating automatically Using Outlook 0
I Saving attachments from multiple emails and updating file name Outlook VBA and Custom Forms 0
G Updating VbaProject.OTM on several users Outlook VBA and Custom Forms 3
RBLampert Updating from Outlook 2010 to Outlook 365 Using Outlook 0
T Office 2013 no longer updating automatically Using Outlook 2
G Mass Updating Contact form used Outlook VBA and Custom Forms 8
J Updating existing entry on shared calendar wants to send update from delegate Using Outlook 0
K Can VBA intervene when updating Internet Calendars? Outlook VBA and Custom Forms 5
S Task Update coming as email and not updating task Using Outlook 3
M search takes a loooong time since updating Using Outlook 8
T Shared calendar not updating Using Outlook 1
T Need help with finding/updating task Outlook VBA and Custom Forms 1
TotallyConfused Godaddy Microsoft exchange 2007 stopped updating Exchange Server Administration 1
S Updating the database based on received task Outlook VBA and Custom Forms 3
makinmyway Recent Files Not Updating when Using Insert Hyperlink in Outlook 2013 Using Outlook 0
S Updating between Smartphone and PC Using Outlook 3
M Outlook 10 Inbox not updating Using Outlook 3
H Gmail not updating Outlook Home Using Outlook 17
Aalishaan Outlook 2010 Updating Inbox starts again Using Outlook 0
Alex Hall When updating shared calendar, it does not automatically update personal calendar Using Outlook 3
D Updating Registry to force new task and note items to save in a particular folder Using Outlook 1
K Excel Import Option: Need Help Updating Existing Records BCM (Business Contact Manager) 0
J Shared ICalendars are not updating in Outlook Using Outlook 2
A Updating Outlook Contact Phone Nos to international dialling codes Using Outlook 5
D Outlook 2010 - Pattern for updating task owner in generic mailbox Using Outlook 2
M Constantly updating address book Using Outlook 5
D Multiple Users Updating Custom Form At Same Time Using Outlook 1
M Updating VBA code from outlook 2007 to outlook 2010 Using Outlook 1
D Updating a recurring meeting cuses a reminder to be sent for every occurence. Using Outlook 2
C Message Count not updating Using Outlook 2
H Cannot share calendar, global address book not updating Exchange Server Administration 1
C Updating many contacts at once? BCM (Business Contact Manager) 3
Z Updating .ics files in OUtlook 2010 Using Outlook 1
T Error when updating Internet Calendar Subscriptions Using Outlook 12
R Outlook 2003 - Exchange 2010 global address list not updating Using Outlook 3
A Updating contacts with new information BCM (Business Contact Manager) 1
M updating and saving contacts in Distribution List Outlook VBA and Custom Forms 2
M Updating appointments from Access 07 Outlook VBA and Custom Forms 4
T Appoinments Not Updating after Outlook 2007 SP2 Outlook VBA and Custom Forms 1
N Macro in this Project are disabled Outlook VBA and Custom Forms 2
M Outlook 365 Amending code so macro runs within current new mail window Outlook VBA and Custom Forms 0
M Outlook 365 macro - automatically attach file based on subject line Outlook VBA and Custom Forms 0
J Outlook macro to run before email is being send Outlook VBA and Custom Forms 3
H Macro to Delete Duplicate items in Outlook calendar where title is the same and date is the same Outlook VBA and Custom Forms 0
X Custom icon (not from Office 365) for a macro in Outlook Outlook VBA and Custom Forms 1

Similar threads

Back
Top