V
Venger
Hello -
Trying to copy contents of one field to another but NOT in a custom form.
In a regular Outlook Contacts folder, I have added 5 custom fields (by
doing Customize Current View -> Fields -> New Field...). I would like to
copy from the User Field 1, 2, 3, and 4 into those fields.
So, say one of the custom fields is Industry. I want to copy data from
User Field 1 (where data was imported to) over to the field I created
called Industry.
I have a script that looks like it should work, but it doesn't. At all.
It is below. Any and all help appreciated. Punching someone at Microsoft
for not allowing you to import into custom fields also a bonus.
Thanks!
------
Sub ConvertFields()
Dim objApp As Application
Dim objNS As NameSpace
Dim objFolder As MAPIFolder
Dim objItems As Items
Dim objItem As Object
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
' make sure you have a Contact item
If objItem.Class = olContact Then
' copy data to your custom fields
objItem.UserProperties("Industry") = objItem.User1
objItem.User1 = ""
objItem.Save
End If
Next
End If
Set objItems = Nothing
Set objItem = Nothing
Set objFolder = Nothing
Set objNS = Nothing
Set objApp = Nothing
End Sub
Trying to copy contents of one field to another but NOT in a custom form.
In a regular Outlook Contacts folder, I have added 5 custom fields (by
doing Customize Current View -> Fields -> New Field...). I would like to
copy from the User Field 1, 2, 3, and 4 into those fields.
So, say one of the custom fields is Industry. I want to copy data from
User Field 1 (where data was imported to) over to the field I created
called Industry.
I have a script that looks like it should work, but it doesn't. At all.
It is below. Any and all help appreciated. Punching someone at Microsoft
for not allowing you to import into custom fields also a bonus.
Thanks!
------
Sub ConvertFields()
Dim objApp As Application
Dim objNS As NameSpace
Dim objFolder As MAPIFolder
Dim objItems As Items
Dim objItem As Object
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
' make sure you have a Contact item
If objItem.Class = olContact Then
' copy data to your custom fields
objItem.UserProperties("Industry") = objItem.User1
objItem.User1 = ""
objItem.Save
End If
Next
End If
Set objItems = Nothing
Set objItem = Nothing
Set objFolder = Nothing
Set objNS = Nothing
Set objApp = Nothing
End Sub