OL2002: How to Programmatically Set Journaling for All Contacts (294363)



The information in this article applies to:

  • Microsoft Outlook 2002

This article was previously published under Q294363

SUMMARY

This article provides an Outlook Visual Basic for Applications macro that you can use to programmatically change all of your contacts so that they are automatically set to journal.

MORE INFORMATION

The default setting for journaling contact items is disabled. If you create contacts and then decide to enable journaling for these contacts, set the journal option for each contact:
  1. On the Tools menu, click Options.
  2. On the Preferences tab, click Journal Options.
  3. In the For these contacts box, click each contact for which you want to enable journaling.
If you have a large number of contacts and you want to enable journaling for all of them, it may be more efficient to programmatically change all of the contacts.

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact a Microsoft Certified Partner or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Partners, please visit the following Microsoft Web site: For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site: To create the macro:
  1. On the Tools menu, point to Macro, and then click Macros.
  2. In the Macro Name box, type SetAllContactsToJournal, and then click Create. The Visual Basic Editor starts and automatically creates a subroutine for you.
  3. Type the following lines of code:
    Sub SetAllContactsToJournal()
    
       Dim objContactsFolder As Outlook.MAPIFolder
       Dim objContacts As Outlook.Items
       Dim objContact As Object
       Dim iCount As Integer
    
       ' Specify which contact folder to work with
       Set objContactsFolder = Session.GetDefaultFolder(olFolderContacts)
       Set objContacts = objContactsFolder.Items
    
       iCount = 0
    
       ' Process the changes
       For Each objContact In objContacts
          If TypeName(objContact) = "ContactItem" Then
             If objContact.Journal = False Then
                objContact.Journal = True
                objContact.Save
                iCount = iCount + 1
             End If
          End If
       Next
       
       MsgBox "Number of contacts updated:" & Str$(iCount)
    
       ' Clean up
       Set objContact = Nothing
       Set objContacts = Nothing
       Set objContactsFolder = Nothing
    
    End Sub
    					
  4. On the File menu, click Close and Return to Microsoft Outlook.
To use the macro:
  1. On the Tools menu, point to Macro, and then click Macros.
  2. Click SetAllContactsToJournal, and then click Run.
A window appears that tells you the number of contacts that were updated.

Notes

  • It may take a while to process the items in your Contacts folder.
  • When your contacts are being updated, your pointer does not change to an hourglass.
  • You can assign the macro to a button if you use this often.For additional information about assigning this macro to a toolbar button, click the article number below to view the article in the Microsoft Knowledge Base:

    292797 OL2002: How to Assign a Macro to a Toolbar Button

  • The sample code only works with the default Contacts folder. If you want it to work with any contacts folder, locate the following line of code
    Set objContactsFolder = Session.GetDefaultFolder(olFolderContacts)
    						
    and change it to:
    Set objContactsFolder = Outlook.ActiveExplorer.CurrentFolder
    					
  • If you are familiar with programming and want to use a specific contacts folder in a different location, see the following article in the Microsoft Knowledge Base:

290804 OL2002: Programming Examples for Referencing Items and Folders

REFERENCES

For additional information about available resources and answersto commonly asked questions about Microsoft Outlook solutions, click the article number below to view the article in the Microsoft Knowledge Base:

287530 OL2002: Questions About Custom Forms and Outlook Solutions


Modification Type:MajorLast Reviewed:6/23/2005
Keywords:kbDSWNET2003Swept kbhowto KB294363