A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Problem copying User1 data to custom-defined field



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old November 29th 06, 10:04 PM posted to microsoft.public.outlook.program_vba
Phyllis Blans
external usenet poster
 
Posts: 1
Default Problem copying User1 data to custom-defined field

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 he
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

Ads
  #2  
Old November 29th 06, 10:21 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Problem copying User1 data to custom-defined field

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?

--
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" wrote in message ups.com...
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 he
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

  #3  
Old November 29th 06, 10:34 PM posted to microsoft.public.outlook.program_vba
Phyllis
external usenet poster
 
Posts: 2
Default Problem copying User1 data to custom-defined field


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

Sue Mosher [MVP-Outlook] wrote:
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?

--
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


  #4  
Old November 29th 06, 11:15 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Problem copying User1 data to custom-defined field

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

--
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" wrote in message s.com...

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

Sue Mosher [MVP-Outlook] wrote:
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?


  #5  
Old November 30th 06, 01:39 AM posted to microsoft.public.outlook.program_vba
Phyllis
external usenet poster
 
Posts: 2
Default Problem copying User1 data to custom-defined field

Yeehaa! Success!

Thanks very much. I really appreciate the quick response!
Phyllis

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Formatting User1 Field to MM/DD/YY? Josh H Outlook - Using Contacts 1 November 17th 06 04:04 PM
Copying Data form user field to custom field [email protected] Outlook - Using Contacts 1 September 4th 06 07:32 PM
Copying all Outlook data to new computer Temp556 Outlook - Using Contacts 1 August 20th 06 06:27 AM
problem in adding value to custom field in inbox Zoom Outlook and VBA 1 May 28th 06 02:40 PM
User Defined Field Initial Value Matt Outlook and VBA 1 May 6th 06 07:54 AM


All times are GMT +1. The time now is 08:50 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.