altschuler
asked on
Referencing the current view records only
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.Cur rentFolder
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(strDa teSelect) = 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
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.Cur
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.
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER