PDA

View Full Version : Solved: Error 438: Outlook 2007



Paleo
08-07-2012, 12:32 PM
Hi everyone,

I am getting error 438 on a code only in Outlook 2007. In outlook 2010 it works like a charm.

The code is:
newTel = LTrim(RTrim(Replace(Replace(Replace(Replace(RTrim(objItem.MobileTelephoneNu mber), "(", ""), ")", ""), "-", ""), " ", "")))

Did I use something I wasnt supposed to use in Outlook 2007?
I simply want to remove spaces, brackets and dashs.

Any clues?

JP2112
08-08-2012, 06:49 AM
ContactItem.MobileTelephoneNumber is a valid property in Outlook 2007.

Is objItem referring to a ContactItem in both Outlook 2007 and 2010? Does objItem have a value in the mobile phone number field in both versions?

Paleo
08-08-2012, 11:41 AM
I believe so JP2112 (http://www.vbaexpress.com/forum/member.php?u=18946),

The code preceding that one is:
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.MobileTelephoneNu mber), "(", ""), ")", ""), "-", ""), " ", "")))

BrianMH
08-10-2012, 09:32 AM
Just tested it in outlook 2007. I'm guessing you have some distribution lists in your contacts.

Try

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
If objItem.Class = olContact Then
newTel = LTrim(RTrim(Replace(Replace(Replace(Replace(RTrim(objItem.MobileTelephoneNu mber), "(", ""), ")", ""), "-", ""), " ", "")))
End If
Next
End If


That worked for me.

Paleo
08-14-2012, 06:52 AM
Thanks, worked.