Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming VBA / November 2006

Tip: Looking for answers? Try searching our database.

Problem copying User1 data to custom-defined field

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Phyllis  Blans - 29 Nov 2006 21:04 GMT
Hi all,

Very novice user here. After importing contacts from an Excel file into
Outlook 2003, I have mapped 1 item to User Field 1. I now need to copy
that value into a custom-defined field called "Specialty".

I started out with the code I got from here:
http://www.outlookcode.com/d/code/convertfields.htm and modified as
needed (modified code below).

PROBLEM
This is only working on the first record in the list. All subsequent
records remain blank.

CODE
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
     If objItem.Class = olContact Then
       objItem.UserProperties("Specialty") = objItem.User1
       objItem.Save
     End If
   Next
 End If

What am I missing? Thanks for any help you can provide.
Phyllis
Sue Mosher [MVP-Outlook] - 29 Nov 2006 21:21 GMT
The code you have assumes that all the items are using a custom form that has the Specialty property defined in it. Is that indeed the case? ALso have you checked the actual values in User1 to make sure they're non-blank?

Signature

Sue Mosher, Outlook MVP
  Author of Configuring Microsoft Outlook 2003
    http://www.turtleflock.com/olconfig/index.htm
  and Microsoft Outlook Programming - Jumpstart for
    Administrators, Power Users, and Developers
    http://www.outlookcode.com/jumpstart.aspx
 
"Phyllis Blans" <cdrivanova@gmail.com> wrote in message news:1164834263.427236.116440@80g2000cwy.googlegroups.com...

> Hi all,
>
[quoted text clipped - 33 lines]
> What am I missing? Thanks for any help you can provide.
> Phyllis
Phyllis - 29 Nov 2006 21:34 GMT
Ah ... that's probably the problem. I don't have a custom form, I'm
just viewing the fields in a Phone List format (added those columns
into the view so that I can check the work). I did check that User
Field 1 includes the content. It's there ...

So, what would I need to adjust in my code to remove the reference to
the custom form?

Thanks for your help ... it shoudl be simple, but as I said, I'm really
novice with VBA.
Phyllis

> The code you have assumes that all the items are using a custom form that has the Specialty property defined in it. Is that indeed the case? ALso have you checked the actual values in User1 to make sure they're non-blank?
>
[quoted text clipped - 5 lines]
>      Administrators, Power Users, and Developers
>      http://www.outlookcode.com/jumpstart.aspx
Sue Mosher [MVP-Outlook] - 29 Nov 2006 22:15 GMT
You don't need a custom form.You can just add the property using the UserProperties.Add method:

Set newProp = theItem.UserProperties.Add("Specialty", olText)
newProp.Value = theItem.User1
theItem.Save

Signature

Sue Mosher, Outlook MVP
  Author of Configuring Microsoft Outlook 2003
    http://www.turtleflock.com/olconfig/index.htm
  and Microsoft Outlook Programming - Jumpstart for
    Administrators, Power Users, and Developers
    http://www.outlookcode.com/jumpstart.aspx
 

>
> Ah ... that's probably the problem. I don't have a custom form, I'm
[quoted text clipped - 10 lines]
>
>> The code you have assumes that all the items are using a custom form that has the Specialty property defined in it. Is that indeed the case? ALso have you checked the actual values in User1 to make sure they're non-blank?
Phyllis - 30 Nov 2006 00:39 GMT
Yeehaa! Success!

Thanks very much. I really appreciate the quick response!
Phyllis
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2010 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.