Ontem falando com um amigo, ele me disse que sempre armazenava os telefones com o código da operadora na frente e que portanto meu código não funcionaria para ele. Pois aqui está o código adaptado para este tipo de cenário.
De quebra ele ainda adiciona os parênteses, os espaços e os hifens aos números onde o 9 já havia sido adicionado.
Sub AlteraTelefones()
'Autor: Carlos Fernando Paleo da Rocha
Dim objApp As Application
Dim objNS As NameSpace
Dim objFolder As MAPIFolder
Dim objItems As Items
Dim objItem As Object
Dim newTel As String
Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
Set objFolder = objNS.PickFolder
If Not objFolder Is Nothing Then
Set objItems = objFolder.Items
For Each objItem In objItems
newTel = LTrim(RTrim(Replace(Replace(Replace(Replace(RTrim(objItem.MobileTelephoneNumber), "(", ""), ")", ""), "-", ""), " ", "")))
Select Case Len(newTel)
Case 10
If Left(newTel, 2) = "11" Then
objItem.MobileTelephoneNumber = "(" & Left(newTel, 2) & ") 9" & Left(Right(newTel, Len(newTel) - 2), 4) & "-" & Right(newTel, 4)
objItem.Save
End If
Case 11
If Left(newTel, 3) = "011" Then
objItem.MobileTelephoneNumber = "(" & Left(newTel, 3) & ") 9" & Left(Right(newTel, Len(newTel) - 3), 4) & "-" & Right(newTel, 4)
objItem.Save
ElseIf Left(newTel, 3) = "119" Then
objItem.MobileTelephoneNumber = "(" & Left(newTel, 2) & ") " & Left(Right(newTel, Len(newTel) - 2), 5) & "-" & Right(newTel, 4)
objItem.Save
End If
Case 12
If Left(newTel, 4) = "0119" Then
objItem.MobileTelephoneNumber = "(" & Left(newTel, 3) & ") " & Left(Right(newTel, Len(newTel) - 3), 5) & "-" & Right(newTel, 4)
objItem.Save
End If
Case 13
If Right(Left(newTel, 5), 2) = "11" Then
objItem.MobileTelephoneNumber = Left(newTel, 3) & " (" & Right(Left(newTel, 5), 2) & ") 9" & Left(Right(newTel, Len(newTel) - 5), 4) & "-" & Right(newTel, 4)
objItem.Save
End If
End Select
Next
End If
Set objItems = Nothing
Set objItem = Nothing
Set objFolder = Nothing
Set objNS = Nothing
Set objApp = Nothing
End Sub
Para saber como utilizar este código veja a explicação neste post.