• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Answered street address fields contain 0A0D

Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
A 'play' with some third party software left me with a corrupt (unbacked-up :() contacts list. Several exports/imports via CSV to/from Excel got me back to what looked to be an okay position... BUT... Now, I have found that some of the street address fields have 0A0D embedded within them and I could do with a way of removing them without exporting/editing/reimporting through Excel.

It has become an issue as I need to export some of the contacts to MailChimp for a mailing campaign.

Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server 2010
Assuming your text is now on a single line, after you make a backup you can try replacing the 0A0D in the text.

Private Sub ContactFolderItems_replace_0A0D()

Dim cFolder As folder
Dim cItem As Object
Dim i As Long

' 0A = Line feed
' 0D = Carriage return

Set cFolder = Session.GetDefaultFolder(olFolderContacts)

For i = 1 To cFolder.Items.count
    Set cItem = cFolder.Items(i)
    If cItem.Class = olContact Then
        ' there are other Address related properties - BusinessAddress
        ' https://msdn.microsoft.com/en-us/vba/outlook-vba/articles/contactitem-object-outlook
        If InStr(cItem.HomeAddress, "0A0D") Then
            'Debug.Print cItem.HomeAddress
            ' Two lines
            cItem.HomeAddress = Replace(cItem.HomeAddress, "0A0D", vbLf & vbCr)
            ' or one line
            ' cItem.HomeAddress = Replace(cItem.HomeAddress, "0A0D", vbLf)
            ' or one line
            ' cItem.HomeAddress = Replace(cItem.HomeAddress, "0A0D", vbCr)
            'Debug.Print cItem.HomeAddress
            ' Save manually after confirming 0A0D is not a legitimate part of the address
            Exit For    ' Remove once solution is confirmed
            ' or autosave, instead of Display, once solution is confirmed
            ' cItem.Save
        End If
    End If


End Sub

Similar threads