![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
I flag certain messages that I get with a certain color flag. I would
like to create a button that could remove that color flag from those messages all at once. The end result would be the messages would no longer have a flag. How would I accomplish this? |
Ads |
#3
|
|||
|
|||
![]()
I tried this code but I am getting an error for the line that states"If
Mail.FlagIcon=olYellowFlagIcon" Public Sub RemoveYellowFlagFromMessages() Dim Items As Outlook.Items Dim Mail As Outlook.MailItem Dim obj As Object Set Items = Application.Session.GetDefaultFolder(olFolderInbox ).Items For Each obj In Items If TypeOf Item Is Outlook.MailItem Then Set Mail = Item If Mail.FlagIcon=olYellowFlagIcon Mail.FlagIcon = olNoFlagIcon Mail.FlagRequest = vbNullString Mail.Save End If End If Next End Sub |
#4
|
|||
|
|||
![]()
Am 2 May 2006 09:02:06 -0700 schrieb :
Simply add a "then" at the end of that line. The syntax is: If ... Then ... -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook -- www.vbOffice.net -- I tried this code but I am getting an error for the line that states"If Mail.FlagIcon=olYellowFlagIcon" Public Sub RemoveYellowFlagFromMessages() Dim Items As Outlook.Items Dim Mail As Outlook.MailItem Dim obj As Object Set Items = Application.Session.GetDefaultFolder(olFolderInbox ).Items For Each obj In Items If TypeOf Item Is Outlook.MailItem Then Set Mail = Item If Mail.FlagIcon=olYellowFlagIcon Mail.FlagIcon = olNoFlagIcon Mail.FlagRequest = vbNullString Mail.Save End If End If Next End Sub |
#5
|
|||
|
|||
![]()
Thanks. I added that and tried it again. I don't get an error now,
but nothing seems to happen. I have 10 messages in my inbox with a yellow flag. When I ran the macro, I expected it to clear the flag from those items, but nothing happened. Here is the code I have. Do I need to change anything else? I even tried selecting the messages first, but that didn't help. Public Sub RemoveYellowFlagFromMessages() Dim Items As Outlook.Items Dim Mail As Outlook.MailItem Dim obj As Object Set Items = Application.Session.GetDefaultFolder(olFolderInbox ).Items For Each obj In Items If TypeOf Item Is Outlook.MailItem Then Set Mail = Item If Mail.FlagIcon = olYellowFlagIcon Then Mail.FlagIcon = olNoFlagIcon Mail.FlagRequest = vbNullString Mail.Save End If End If Next End Sub |
#6
|
|||
|
|||
![]()
Am 3 May 2006 17:08:24 -0700 schrieb :
For Each obj In Items If TypeOf Item Is Outlook.MailItem Then Set Mail = Item "Item" is not a declared variable. Replace it please by "obj". -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook -- www.vbOffice.net -- Thanks. I added that and tried it again. I don't get an error now, but nothing seems to happen. I have 10 messages in my inbox with a yellow flag. When I ran the macro, I expected it to clear the flag from those items, but nothing happened. Here is the code I have. Do I need to change anything else? I even tried selecting the messages first, but that didn't help. Public Sub RemoveYellowFlagFromMessages() Dim Items As Outlook.Items Dim Mail As Outlook.MailItem Dim obj As Object Set Items = Application.Session.GetDefaultFolder(olFolderInbox ).Items For Each obj In Items If TypeOf Item Is Outlook.MailItem Then Set Mail = Item If Mail.FlagIcon = olYellowFlagIcon Then Mail.FlagIcon = olNoFlagIcon Mail.FlagRequest = vbNullString Mail.Save End If End If Next End Sub |
#7
|
|||
|
|||
![]()
I made that change.....still not working. Is there something else I'm
missing? Public Sub RemoveYellowFlagFromMessages() Dim Items As Outlook.Items Dim Mail As Outlook.MailItem Dim obj As Object Set Items = Application.Session.GetDefaultFolder(olFolderInbox ).Items For Each obj In Items If TypeOf Item Is Outlook.MailItem Then Set Mail = obj If Mail.FlagIcon = olYellowFlagIcon Then Mail.FlagIcon = olNoFlagIcon Mail.FlagRequest = vbNullString Mail.Save End If End If Next End Sub |
#8
|
|||
|
|||
![]()
Am 4 May 2006 18:59:57 -0700 schrieb :
No, you didn´t. See: If TypeOf Item Is Outlook.MailItem Then -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook -- www.vbOffice.net -- I made that change.....still not working. Is there something else I'm missing? Public Sub RemoveYellowFlagFromMessages() Dim Items As Outlook.Items Dim Mail As Outlook.MailItem Dim obj As Object Set Items = Application.Session.GetDefaultFolder(olFolderInbox ).Items For Each obj In Items If TypeOf Item Is Outlook.MailItem Then Set Mail = obj If Mail.FlagIcon = olYellowFlagIcon Then Mail.FlagIcon = olNoFlagIcon Mail.FlagRequest = vbNullString Mail.Save End If End If Next End Sub |
#9
|
|||
|
|||
![]()
I'm not understanding what you're saying I should change. I have a
line that states If TypeOf Item Is Outlook.MailItem Then. What part do I need to fix? I don't have any skill with Outlook VBA, so I'm basically looking to just copy and paste the code. |
#10
|
|||
|
|||
![]()
Reread Michael's earlier post, in which he said:
"Item" is not a declared variable. Replace it please by "obj". You also need to remove the flag itself: Mail.FlagStatus = olNoFlag -- Sue Mosher, Outlook MVP Author of Configuring Microsoft Outlook 2003 http://www.turtleflock.com/olconfig/index.htm and Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx wrote in message ups.com... I'm not understanding what you're saying I should change. I have a line that states If TypeOf Item Is Outlook.MailItem Then. What part do I need to fix? I don't have any skill with Outlook VBA, so I'm basically looking to just copy and paste the code. "Michael Bauer" wrote in message ... Am 4 May 2006 18:59:57 -0700 schrieb : No, you didn´t. See: If TypeOf Item Is Outlook.MailItem Then -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook -- www.vbOffice.net -- I made that change.....still not working. Is there something else I'm missing? Public Sub RemoveYellowFlagFromMessages() Dim Items As Outlook.Items Dim Mail As Outlook.MailItem Dim obj As Object Set Items = Application.Session.GetDefaultFolder(olFolderInbox ).Items For Each obj In Items If TypeOf Item Is Outlook.MailItem Then Set Mail = obj If Mail.FlagIcon = olYellowFlagIcon Then Mail.FlagIcon = olNoFlagIcon Mail.FlagRequest = vbNullString Mail.Save End If End If Next End Sub |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Using VBA code to automate a process | [email protected] | Outlook and VBA | 7 | April 21st 06 05:26 PM |
Code to set an auto follow up flag | A Don | Outlook - Using Forms | 1 | April 21st 06 12:19 PM |
Code to set Flag Status to complete on custom form | ICT User | Outlook - Using Forms | 3 | March 28th 06 12:59 AM |
how to apply vba code to OL2003 forms ? | TimR | Outlook - Using Contacts | 1 | February 17th 06 05:41 PM |
VBA Code to check Task Status | [email protected] | Outlook and VBA | 2 | February 3rd 06 07:16 PM |