Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > VBA / Office Integration > Word, PowerPoint, Outlook, and Other Office Products > Outlook Macro - Remove FW: from Subject Lines


Reply
 
Thread Tools Display Modes
  #1  
Old 03-29-2012, 06:48 AM
jcleary47 jcleary47 is offline
Newcomer
 
Join Date: May 2008
Posts: 24
Default Outlook Macro - Remove FW: from Subject Lines


I'm trying to build a macro to remove the FW: from the subject line for selected emails. The code runs through but doesn't alter the subject line.

I can't figure out why

Code:
Sub SubjectFix()

On Error Resume Next
    Dim objFolder As Outlook.MAPIFolder
    Dim objNS As Outlook.NameSpace, objItem As Outlook.MailItem
    Dim folderID As String
    
     Set objNS = Application.GetNamespace("MAPI")

For Each objItem In Application.ActiveExplorer.Selection
   'If objFolder.DefaultItemType = olMailItem Then
      If objItem.Subject = "FW: blah blah blah" Then
         objItem.Subject = "blah blah blah"
      End If
Next

End Sub
Reply With Quote
  #2  
Old 03-29-2012, 06:54 AM
jcleary47 jcleary47 is offline
Newcomer
 
Join Date: May 2008
Posts: 24
Default

Errr okay so it does update...in the email preview window it shows it as being updated, but in the outlook inbox window it doesn't show as updated.

If I open the email it's corrected and asks me if I want to save the changes when I close the email.

Any thoughts on why it's not auto-updating unless I go in and save it?
Reply With Quote
  #3  
Old 03-29-2012, 06:57 AM
DrPunk's Avatar
DrPunk DrPunk is offline
Senior Contributor

* Expert *
 
Join Date: Apr 2003
Location: Never where I want to be
Posts: 1,276
Default

Maybe call .Save of the MailItem after changing it?
__________________
There are no computers in heaven!
Reply With Quote
  #4  
Old 03-29-2012, 07:02 AM
jcleary47 jcleary47 is offline
Newcomer
 
Join Date: May 2008
Posts: 24
Default

.Save worked like a charm.

Thanks so much! Not sure how that idea slipped my mind!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->