• Title repeats (2003/SR-2)

    Author
    Topic
    #427422

    When I use my contact list in MS Word, the title repeats twice. e.g.

    Mr & Mrs. Mr. & Mrs. John Jones, etc.

    I can cure this in Outlook manually by opening an individual contact, deleting the title in the name, retyping the title, saving & closing.
    1) Is there a way to cure this in Outlook without opening each contact individually?
    2) Is there a macro solution that would do this (not all contacts have a title)?

    Thanks in advance,

    Viewing 0 reply threads
    Author
    Replies
    • #990318

      (Edited by JohnBF on 15-Dec-05 15:46. )

      1. Yes, by using 2.
      2. See if this works.

      Edit: Code removed, see post 542789 for corrected and improved version.

      Anecdotal comment: it is still annoying to me that Outlook does not have a Find-and-Replace function.

      • #990356

        Hi John:
        Thanks for this. But what it did is remove everything before the name except the “&”. Now each name has something like “& John Jones”. I wanted to keep the title, but not have it repeat twice in Word. Can I get the titles back?

        Later: OK. I got the titles back by restoring from a backup. Is it possible to have the macro step through each contact, hold the titles in some sort of variable, delete the title, save it, then put the title back & save it. It would also have to work for titles like Mr. & Mrs., Dr. & Mrs. without leaving the and. Thanks again for all the work.

        • #990508

          Phil, I sincerely apologize that I messed you up. It might be safest to make a complete copy of your Contacts Folder and run any code on that (one advantage of using the PickFolder Method instead of using the default Contact Folder).

          Are you using the Word the mail merge from Contacts function? I can’t help us much as I would like because I don’t know exactly what Word is picking up in that process, so in my reply Post I assumed that you would delete the Title from Outlook’s Full Name Field, and in your mail merge you would select the title from Outlook’s Title field. But I’m a bit lost on how you end up with double titles.

          After creating a copy of the Contact Folder so that I don’t destroy your records any more, you should be able to add additional search text to the Array line above, like:

          varTitles = Array(“Mr. & Mrs.”, “Dr.”, “Miss”, “Mr.”, “Mrs.”, “Ms.”, “Prof.”, ” & “) ‘ note spaces around ampersand

          Does this help?

          • #990511

            Hi John:
            No problem; I appreciate the help. I should have made a backup anyhow. Two questions:
            1) I know I can make a copy of my Outlook.pst file, try out the macro, & simply delete the Outlook.pst file & rename the copy if it doesn’t work out. Is there a way to backup just the contacts, as the Outlook.pst file backs up everything.
            2) Will the macro, with your changes, delete the titles & then replace them with the same titles? i.e. will
            Mr. & Mrs. John Jones
            Mr. Tom Smith

            end up with the same titles after running your macro?

            I’m not using a mail merge in Word. Word has an “Insert Address” button, which inserts the name & address from a database at the insertion point. It will use Outlook contacts list. Since I use it to address individual letters, including the title, I don’t want to lose the title. I don’t know what I did to cause the problem, or why deleting & retyping them cures the problem, but it does. My other option is to go through a few hundred names individually, but, of course, a macro would be faster. smile

            Thanks again,

            • #990524

              1. I’d recommend instead that you create a new Contacts Folder within your PST and copy all contacts to it. (See post 539283.)

              2. No, it does not. The immediate fix should be to change this line from

              .FullName = Replace(.FullName, varTitles(intT), “”, 1, 1, vbTextCompare)

              to

              .FullName = .Title & Replace(.FullName, varTitles(intT), “”, 1, 1, vbTextCompare)

              But in a quick test it does not seem to work correctly. scratch

              Before we go any further, can you tell me the steps you use to insert the Contact Address from Outlook to your Word doc?

            • #990545

              Hi John:
              I use the following steps to insert the contact address into Word:
              1. Start Outlook (not actually necessary, but it saves one click in Word).
              2. Open any document in Word.
              3. I have an Insert Address button on my toolbar, but it’s the same one that’s found under Tools/Letters & Mailings…/Envelopes & Labels…
              4. On the top of the dialog box that opens is an open book icon, which is the insert address icon. I click it & select a name from the list.

              I was inconsistent in the way I entered contacts. Some had a title, some didn’t. In Word, there is an autotext entry which inserts the title, followed by the display name, when you use the Insert Address command with Outlook Contacts as a database. I could change the autotext entry in Word to omit the title, but then some names wouldn’t have a title. I’m guessing that I caused this in Outlook by entering something like: John Jones (& then adding the title “Mr.”) in some circumstances & in others, I entered Mr. John Jones. Outlook 2003 seems to understand that the titles are not part of the name, but older versions of Outlook, where I created many of the contact names, didn’t understand this.

              If the macro can be altered easily, that would be the preferred solution. I appreciate the trouble that you’ve gone to, John. If it requires too much work, I think I can just do it manually. At 4/minute, it’ll probably just take over a hour. At least it’s not a business list containing thousands. grin

            • #990565

              There’s a strange interaction between the “Title” field and the “FullName” field that I had not encountered before because I don’t use Titles, and I still don’t really understand it, but it looks like they automatically attempt to populate each other. With that in mind, and a little testing, this (famous last words) works for me, run it on your copies crossfingers:

              Sub RemoveContactFullNameTitle()
              Dim fldrContFldr As MAPIFolder
              Dim lngC As Long
              Dim intT As Integer
              Dim varTitles As Variant
              Dim strTempTitle As String

              varTitles = Array(“Mr. & Mrs.”, “Dr.”, “Miss”, “Mr.”, “Mrs.”, “Ms.”, “Prof.”)
              Set fldrContFldr = Outlook.Session.PickFolder
              If Not fldrContFldr Is Nothing Then
              If fldrContFldr.DefaultItemType = olContactItem Then
              For lngC = 1 To fldrContFldr.Items.Count
              If fldrContFldr.Items(lngC).Class = olContact Then ‘ skip distlists
              With fldrContFldr.Items(lngC)
              strTempTitle = .Title
              For intT = 0 To UBound(varTitles)
              .FullName = Replace(.FullName, varTitles(intT), “”, 1, 1, vbTextCompare)
              Next intT
              .Title = strTempTitle
              .Save
              End With
              End If
              Next lngC
              End If
              End If
              Set varTitles = Nothing
              Set fldrContFldr = Nothing
              End Sub

            • #990595

              Thank you, John. Worked like a charm bravo. Even better than I had hoped, because although it took all the titles off the display name, it puts them in when I insert them. Also, when I sync’d to my PDA, it left all the titles in, so it works just like the desktop Outlook. I expected it to take awhile to sync, but it didn’t require any changes. Anyway, thanks again for all your time. I can’t wait to get the rest of my computer back in order so I can start contributing again. evilgrin

    Viewing 0 reply threads
    Reply To: Title repeats (2003/SR-2)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: