VB: clear flag/reminder - this doesn't work completely for O2003 ...
-
Tuesday, April 10, 2012 3:56 PM
Hi,
I have this macro that I've been using for several years now:
****************************************************************
Sub ClearFlag()
' this works for Outlook 2000Dim objOL As Outlook.Application
Dim colSel As Outlook.Selection
Dim objItem As Object
' ------------------------------------------------------------------------------
' Set objOL = CreateObject("Outlook.Application")
' for Outlook 2003 or other, if this doesn't work, change the line right above to this below:
Set objOL = Application
' ------------------------------------------------------------------------------
Set colSel = objOL.ActiveExplorer.Selection
For Each objItem In colSel
If objItem.Class = olMail Then
If objItem.FlagStatus <> olNoFlag Then
With objItem
.FlagDueBy = #1/1/4501#
.FlagRequest = ""
.FlagStatus = olNoFlag
Mail.FlagStatus = olNoFlag
'--------------------------------------------------------------------------------
' Also for Outlook 2003 and beyond, you can activate this line of code right here below:
.FlagIcon = olNoFlagIcon
'--------------------------------------------------------------------------------
.Save
End With
End If
End If
Next
Set objOL = Nothing
Set colSel = Nothing
Set objItem = Nothing
End Sub****************************************************************
Despite having the .FlagIcon = olNoFlagIcon line above, the macro removes the reminder but actually doesn't set the flag to NONE which is needed.
Does anyone know what coding will remove the flag and set it to NONE?
Thanks!!! :oD
All Replies
-
Thursday, April 12, 2012 6:22 AMModerator
Hi SGFan,
Thanks for posting in the MSDN Forum.
I tried to clean up flag via following snippet under XP, Outlook 2003:
Sub test() Dim msg As Object For Each msg In Application.ActiveExplorer.Selection If msg.Class = olMail Then If msg.FlagStatus <> olNoFlag Then With msg .FlagDueBy = #1/1/4501# .FlagRequest = "" .FlagStatus = olNoFlag .FlagIcon = olNoFlagIcon .Save End With End If End If Next End SubIt works fine on my side.
I recommend you try it to see whether it can solve your issue.
Have a good day,
Tom
Tom Xu [MSFT]
MSDN Community Support | Feedback to us
- Marked As Answer by Tom_Xu_WXModerator Monday, April 16, 2012 5:44 AM
-
Thursday, April 12, 2012 4:26 PM
Tom, thank you! This is VERY nice. It worked!
And, bonus, it worked on a test I did on a couple of selected unopened email messages in my inbox that had flags on them - which means that the macro doesn't need to be invoked manually on individual closed email messages; it can be invoked on several selected messages. Very kewl!
Phew, this task has now been made a lot easier. I have rules that assign flags that then need to be cleared once tasks in emails have been dealt with and it's been a pain to do it manually.
I'll be testing this out and I'll report back if any troubles, but so far, so good!
Thanks and cheers!
-
Friday, April 13, 2012 5:56 AMModerator
Hi SGFan,
I'm glad to hear that can work for you.
Have a good day,
Tom
Tom Xu [MSFT]
MSDN Community Support | Feedback to us
- Edited by Tom_Xu_WXModerator Friday, April 13, 2012 5:57 AM
-
Monday, April 16, 2012 4:14 PM
Hi SGFan,
I'm glad to hear that can work for you.
Have a good day,
Tom
Hi, I've been using the macro daily and just wanted to report back one thing this doesn't work on: emails that are meeting invites that are flagged and moved through a rule. The rule takes all messages that are listed in the rules as "which is a meeting invite or update", then flags it with "flag message for Follow up within 0 days" and action is "and move it to the meeting" folder.
The macro above doesn't clear the flags on these and I can't even clear them manually. Yet the rule needs to remain; that does a superb job. Is there a separate macro that I can run on selected meeting invites to remove the reminder and flag? Once the rule has been run and I've been informed, I don't need the flag/reminder so it was be neat to be able to remove them.
Pls advsie and thanks!
-
Thursday, April 19, 2012 9:59 PM
This above question is related directly to this macro and is not a separate query. The macro spoken of in this "thread" works on all but meeting invitations that have been flagged by a rule.
How can we modify the above macro to clear those messages of flags that are actually invites, pls? That will cover all clearing of automatic flagging in Outlook 2003.
Thank you! :oD
-
Friday, April 20, 2012 12:57 PMModeratorThe macro code is testing for:If msg.Class = olMail Then
To test for other types of items you need to add one or more OR clauses to your If test. Depending on exactly what you're looking for you might use olMeetingRequest. Take a look at the OlObjectClass enumeration in the Outlook VBA project's Object Browser.If ((msg.Class = olMail) OR (msg.Class = olMeetingRequest)) Then
"SGFan" <=?utf-8?B?U0dGYW4=?=> wrote in message news:05b4aa2b-37be-4066-ab92-1f31646cd98c...This above question is related directly to this macro and is not a separate query. The macro spoken of in this "thread" works on all but meeting invitations that have been flagged by a rule.
How can we modify the above macro to clear those messages of flags that are actually invites, pls? That will cover all clearing of automatic flagging in Outlook 2003.
Thank you! :oD
Ken Slovak MVP - Outlook -
Monday, June 11, 2012 5:53 PMThe macro code is testing for:If msg.Class = olMail Then
To test for other types of items you need to add one or more OR clauses to your If test. Depending on exactly what you're looking for you might use olMeetingRequest. Take a look at the OlObjectClass enumeration in the Outlook VBA project's Object Browser.If ((msg.Class = olMail) OR (msg.Class = olMeetingRequest)) Then
Ken, hi!
Some time has gone by since I posted this. I did find a few other bits of code since then but the one that over eluded me until today was the case of cancelled meetings, I think because I'm not yet 'fluent' in the Object Browser. There are 2 similar bits of code for cancelled meetings. Here's the line as it stands now:
If ((msg.Class = olMail) Or (msg.Class = olMeeting) Or (msg.Class = olMeetingRequest) Or (msg.Class = olMeetingAccepted) Or (msg.Class = olMeetingTentative) Or (msg.Class = olMeetingDeclined) Or (msg.Class = olMeetingCancellation) Or (msg.Class = olMeetingCanceled) Or (msg.Class = olMeetingResponsePositive) Or (msg.Class = olMeetingResponseNegative)) Then
And the 2 similar syntaxes, one of which takes flags off cancelled meetings messages are these 2:
Or (msg.Class = olMeetingCancellation) Or (msg.Class = olMeetingCanceled) Or
olMeetingCancellation is very similar to olMeetingCanceled but one of them only takes off the flag.
Thanks for this. All I need to do to finish fine-tuning this is to have some way for user to know when macro is still in progress.But I'll post in another thread, if need be.
Cheers and thanks!

