Solved

Referencing the current view records only

Posted on 2000-04-06
2
214 Views
Last Modified: 2010-07-27
I am using the code below to update a custom field in our contacts list. This code updates all of the records in the current folder. I would like to modify it to only update the displayed records (i.e. the records shown after I have applied a filter to the current view.) I am working in Outlook 2000. Can anyone suggest a modification?

Sub UpdateDateFields2()
 Dim objContactsFolder As Outlook.MAPIFolder
   Dim objContacts As Outlook.Items
   Dim strDateSelect As String
   Dim strDate As Date
   Dim objContact As Object
   Dim iCount As Integer

   ' Specify which contact folder to work with
   Set objContactsFolder = Outlook.ActiveExplorer.CurrentFolder
   Set objContacts = objContactsFolder.Items

   ' Prompt for field and date
   strDateSelect = InputBox("Enter the field to update.")
   strDate = InputBox("Enter date.")
 

   iCount = 0

   ' Process the changes
   For Each objContact In objContacts
      If TypeName(objContact) = "ContactItem" Then
        objContact.UserProperties.Find(strDateSelect) = strDate
        objContact.Save
        iCount = iCount + 1
      End If
   Next
   
   MsgBox "Number of contacts updated:" & Str$(iCount)

   ' Clean up
   Set objContact = Nothing
   Set objContacts = Nothing
   Set objContactsFolder = Nothing
End Sub
0
Comment
Question by:altschuler
2 Comments
 
LVL 2

Accepted Solution

by:
brice123 earned 70 total points
ID: 2692399
Not a very elegant solution, but at least it works...


 ' Active the current explorer
  Outlook.ActiveExplorer.Activate
 
  ' Select all the visible items  SendKeys ("^A")

   ' Loop through the selection collection
   For Each objContact In Outlook.ActiveExplorer.Selection
      If TypeName(objContact) = "ContactItem" Then
        objContact.UserProperties.Find(strDateSelect) = strDate
        objContact.Save
        iCount = iCount + 1
      End If
   Next
   
   MsgBox "Number of contacts updated:" & Str$(iCount)
0
 

Author Comment

by:altschuler
ID: 2695056
Thanks again. Perfect.
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
Large Outlook files lead to various unwanted errors and corruption issues. Furthermore, large outlook files can also make Outlook take longer to start-up, search, navigate, and shut-down. So, In this article, i will discuss a method to make your Out…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question