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

Problems with Custom Sub to Import to User-Defined Fields



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old November 11th 06, 01:24 PM posted to microsoft.public.outlook.program_vba
dch3
external usenet poster
 
Posts: 105
Default Problems with Custom Sub to Import to User-Defined Fields

The code below was crapping out last night at the point noted below. This
morning it crapped out earlier in the code. I cannot figure out why for the
life of me it does. I do not believe that there's a limit to the number of
User Properties that can be created and have double checked that everything
matches up. The code will eventually import an Excel worksheet into Outlook.
I have been running it from within Excel to push the values to Outlook, would
it be better to run it from within Outlook and pull the values from Excel?

Help?


Sub createOutlookAppointmentFromId()

Dim objOutlook As Object
Dim newAppt As Object
Dim nms As Outlook.Namespace
Dim targetFolder As Object

Set objOutlook = CreateObject("Outlook.application")
Set nms = objOutlook.GetNamespace("MAPI")
Set targetFolder = nms.Folders("Mailbox - David Holley").Folders("Show
Schedule Upload")

'Use PickFolder to select target for import
Set newAppt = objOutlook.CreateItem(olAppointmentItem)

With newAppt.UserProperties
.Add "Show Name", olText
.Add "Job Number", olText
.Add "Facility", olText
.Add "Room", olText
.Add "DP Color", olText
.Add "AS Carpet", olText
.Add "BT Package", olText
.Add "Account Executive", olText
.Add "DE Foreman", olText
.Add "FR Foreman", olText
.Add "XXX Foreman", olText
.Add "SSX Foreman", olText
.Add "ESX IH Rep", olText
.Add "ESX SS Rep", olText
.Add "RGN Move-In Start", olDateTime
.Add "RGN Move-In End", olDateTime
.Add "XXX Move-In Start", olDateTime
.Add "XXX Move-In End", olDateTime
.Add "Dealer Move-In Start", olDateTime
.Add "Dealer Move-In End", olDateTime
.Add "Month", olText
.Add "Show Open", olDateTime
.Add "Show Close", olDateTime
.Add "Dealer Clear", olDateTime
.Add "XXX Clear", olDateTime
End With

With newAppt
.UserProperties(1) = "TEST SHOW NAME"
.UserProperties(2) = "999999"
.UserProperties(3) = "DISNEY'S GRAND FLORIDIAN"
.UserProperties(4) = "Fantasia Ballroom"
.UserProperties(5) = "Blue"
.UserProperties(6) = "Green"
.UserProperties(7) = "No Package"
.UserProperties(8) = "AE"
.UserProperties(9) = "DF" 'CRAP OUT POINT
.UserProperties(10) = "FF"
.UserProperties(11) = "MIS"
.UserProperties(12) = "SS"
.UserProperties(13) = "ESIR"
.UserProperties(14) = "ESSR"
.UserProperties(15) = "10/01/2006 8:00 AM"
.UserProperties(16) = "10/01/2006 8:00 PM"
.UserProperties(17) = "10/02/2006 9:00 AM"
.UserProperties(18) = "10/02/2006 9:00 PM"
.UserProperties(19) = "10/03/2006 10:00 AM"
.UserProperties(20) = "10/03/2006 10:00 PM"
.UserProperties(21) = "2006 11 November"
.UserProperties(22) = "11/1/2006 8:00 AM"
.UserProperties(23) = "11/2/2006 8:01 AM"
.UserProperties(24) = "12/30/2006 10:00 PM"
.UserProperties(25) = "12/31/2006 11:59 PM"
.Save
End With

Set targetFolder = Nothing
Set nms = Nothing
Set newAppt = Nothing
Set objOutlook = Nothing

End Sub
  #2  
Old November 11th 06, 02:33 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Problems with Custom Sub to Import to User-Defined Fields

You shouldn't depend on index numbers to work with custom properties. Instead, set the value at the time you add the property:

Set newProp = .Add "Show Name", olText
newProp.Value = "TEST SHOW NAME"
Set newProp = .Add "Job Number", olText
newProp.Value = "999999"

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

"dch3" wrote in message ...
The code below was crapping out last night at the point noted below. This
morning it crapped out earlier in the code. I cannot figure out why for the
life of me it does. I do not believe that there's a limit to the number of
User Properties that can be created and have double checked that everything
matches up. The code will eventually import an Excel worksheet into Outlook.
I have been running it from within Excel to push the values to Outlook, would
it be better to run it from within Outlook and pull the values from Excel?

Help?


Sub createOutlookAppointmentFromId()

Dim objOutlook As Object
Dim newAppt As Object
Dim nms As Outlook.Namespace
Dim targetFolder As Object

Set objOutlook = CreateObject("Outlook.application")
Set nms = objOutlook.GetNamespace("MAPI")
Set targetFolder = nms.Folders("Mailbox - David Holley").Folders("Show
Schedule Upload")

'Use PickFolder to select target for import
Set newAppt = objOutlook.CreateItem(olAppointmentItem)

With newAppt.UserProperties
.Add "Show Name", olText
.Add "Job Number", olText
.Add "Facility", olText
.Add "Room", olText
.Add "DP Color", olText
.Add "AS Carpet", olText
.Add "BT Package", olText
.Add "Account Executive", olText
.Add "DE Foreman", olText
.Add "FR Foreman", olText
.Add "XXX Foreman", olText
.Add "SSX Foreman", olText
.Add "ESX IH Rep", olText
.Add "ESX SS Rep", olText
.Add "RGN Move-In Start", olDateTime
.Add "RGN Move-In End", olDateTime
.Add "XXX Move-In Start", olDateTime
.Add "XXX Move-In End", olDateTime
.Add "Dealer Move-In Start", olDateTime
.Add "Dealer Move-In End", olDateTime
.Add "Month", olText
.Add "Show Open", olDateTime
.Add "Show Close", olDateTime
.Add "Dealer Clear", olDateTime
.Add "XXX Clear", olDateTime
End With

With newAppt
.UserProperties(1) = "TEST SHOW NAME"
.UserProperties(2) = "999999"
.UserProperties(3) = "DISNEY'S GRAND FLORIDIAN"
.UserProperties(4) = "Fantasia Ballroom"
.UserProperties(5) = "Blue"
.UserProperties(6) = "Green"
.UserProperties(7) = "No Package"
.UserProperties(8) = "AE"
.UserProperties(9) = "DF" 'CRAP OUT POINT
.UserProperties(10) = "FF"
.UserProperties(11) = "MIS"
.UserProperties(12) = "SS"
.UserProperties(13) = "ESIR"
.UserProperties(14) = "ESSR"
.UserProperties(15) = "10/01/2006 8:00 AM"
.UserProperties(16) = "10/01/2006 8:00 PM"
.UserProperties(17) = "10/02/2006 9:00 AM"
.UserProperties(18) = "10/02/2006 9:00 PM"
.UserProperties(19) = "10/03/2006 10:00 AM"
.UserProperties(20) = "10/03/2006 10:00 PM"
.UserProperties(21) = "2006 11 November"
.UserProperties(22) = "11/1/2006 8:00 AM"
.UserProperties(23) = "11/2/2006 8:01 AM"
.UserProperties(24) = "12/30/2006 10:00 PM"
.UserProperties(25) = "12/31/2006 11:59 PM"
.Save
End With

Set targetFolder = Nothing
Set nms = Nothing
Set newAppt = Nothing
Set objOutlook = Nothing

End Sub

  #3  
Old November 11th 06, 03:25 PM posted to microsoft.public.outlook.program_vba
dch3
external usenet poster
 
Posts: 105
Default Problems with Custom Sub to Import to User-Defined Fields

and I assume that I have to add the specific user properties for each
individual appointment item?

"Sue Mosher [MVP-Outlook]" wrote:

You shouldn't depend on index numbers to work with custom properties. Instead, set the value at the time you add the property:

Set newProp = .Add "Show Name", olText
newProp.Value = "TEST SHOW NAME"
Set newProp = .Add "Job Number", olText
newProp.Value = "999999"

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

"dch3" wrote in message ...
The code below was crapping out last night at the point noted below. This
morning it crapped out earlier in the code. I cannot figure out why for the
life of me it does. I do not believe that there's a limit to the number of
User Properties that can be created and have double checked that everything
matches up. The code will eventually import an Excel worksheet into Outlook.
I have been running it from within Excel to push the values to Outlook, would
it be better to run it from within Outlook and pull the values from Excel?

Help?


Sub createOutlookAppointmentFromId()

Dim objOutlook As Object
Dim newAppt As Object
Dim nms As Outlook.Namespace
Dim targetFolder As Object

Set objOutlook = CreateObject("Outlook.application")
Set nms = objOutlook.GetNamespace("MAPI")
Set targetFolder = nms.Folders("Mailbox - David Holley").Folders("Show
Schedule Upload")

'Use PickFolder to select target for import
Set newAppt = objOutlook.CreateItem(olAppointmentItem)

With newAppt.UserProperties
.Add "Show Name", olText
.Add "Job Number", olText
.Add "Facility", olText
.Add "Room", olText
.Add "DP Color", olText
.Add "AS Carpet", olText
.Add "BT Package", olText
.Add "Account Executive", olText
.Add "DE Foreman", olText
.Add "FR Foreman", olText
.Add "XXX Foreman", olText
.Add "SSX Foreman", olText
.Add "ESX IH Rep", olText
.Add "ESX SS Rep", olText
.Add "RGN Move-In Start", olDateTime
.Add "RGN Move-In End", olDateTime
.Add "XXX Move-In Start", olDateTime
.Add "XXX Move-In End", olDateTime
.Add "Dealer Move-In Start", olDateTime
.Add "Dealer Move-In End", olDateTime
.Add "Month", olText
.Add "Show Open", olDateTime
.Add "Show Close", olDateTime
.Add "Dealer Clear", olDateTime
.Add "XXX Clear", olDateTime
End With

With newAppt
.UserProperties(1) = "TEST SHOW NAME"
.UserProperties(2) = "999999"
.UserProperties(3) = "DISNEY'S GRAND FLORIDIAN"
.UserProperties(4) = "Fantasia Ballroom"
.UserProperties(5) = "Blue"
.UserProperties(6) = "Green"
.UserProperties(7) = "No Package"
.UserProperties(8) = "AE"
.UserProperties(9) = "DF" 'CRAP OUT POINT
.UserProperties(10) = "FF"
.UserProperties(11) = "MIS"
.UserProperties(12) = "SS"
.UserProperties(13) = "ESIR"
.UserProperties(14) = "ESSR"
.UserProperties(15) = "10/01/2006 8:00 AM"
.UserProperties(16) = "10/01/2006 8:00 PM"
.UserProperties(17) = "10/02/2006 9:00 AM"
.UserProperties(18) = "10/02/2006 9:00 PM"
.UserProperties(19) = "10/03/2006 10:00 AM"
.UserProperties(20) = "10/03/2006 10:00 PM"
.UserProperties(21) = "2006 11 November"
.UserProperties(22) = "11/1/2006 8:00 AM"
.UserProperties(23) = "11/2/2006 8:01 AM"
.UserProperties(24) = "12/30/2006 10:00 PM"
.UserProperties(25) = "12/31/2006 11:59 PM"
.Save
End With

Set targetFolder = Nothing
Set nms = Nothing
Set newAppt = Nothing
Set objOutlook = Nothing

End Sub


  #4  
Old November 11th 06, 06:52 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Problems with Custom Sub to Import to User-Defined Fields

SInce you're creating a new item with objOutlook.CreateItem(olAppointmentItem), it has no custom fields. Therefore, you must add them.

The alternative would be to build the fields into the design of a custom Outlook form and create new form instances with the MAPIFolder.Items.Add method on the Calendar folder.

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

"dch3" wrote in message ...
and I assume that I have to add the specific user properties for each
individual appointment item?

"Sue Mosher [MVP-Outlook]" wrote:

You shouldn't depend on index numbers to work with custom properties. Instead, set the value at the time you add the property:

Set newProp = .Add "Show Name", olText
newProp.Value = "TEST SHOW NAME"
Set newProp = .Add "Job Number", olText
newProp.Value = "999999"

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

"dch3" wrote in message ...
The code below was crapping out last night at the point noted below. This
morning it crapped out earlier in the code. I cannot figure out why for the
life of me it does. I do not believe that there's a limit to the number of
User Properties that can be created and have double checked that everything
matches up. The code will eventually import an Excel worksheet into Outlook.
I have been running it from within Excel to push the values to Outlook, would
it be better to run it from within Outlook and pull the values from Excel?

Help?


Sub createOutlookAppointmentFromId()

Dim objOutlook As Object
Dim newAppt As Object
Dim nms As Outlook.Namespace
Dim targetFolder As Object

Set objOutlook = CreateObject("Outlook.application")
Set nms = objOutlook.GetNamespace("MAPI")
Set targetFolder = nms.Folders("Mailbox - David Holley").Folders("Show
Schedule Upload")

'Use PickFolder to select target for import
Set newAppt = objOutlook.CreateItem(olAppointmentItem)

With newAppt.UserProperties
.Add "Show Name", olText
.Add "Job Number", olText
.Add "Facility", olText
.Add "Room", olText
.Add "DP Color", olText
.Add "AS Carpet", olText
.Add "BT Package", olText
.Add "Account Executive", olText
.Add "DE Foreman", olText
.Add "FR Foreman", olText
.Add "XXX Foreman", olText
.Add "SSX Foreman", olText
.Add "ESX IH Rep", olText
.Add "ESX SS Rep", olText
.Add "RGN Move-In Start", olDateTime
.Add "RGN Move-In End", olDateTime
.Add "XXX Move-In Start", olDateTime
.Add "XXX Move-In End", olDateTime
.Add "Dealer Move-In Start", olDateTime
.Add "Dealer Move-In End", olDateTime
.Add "Month", olText
.Add "Show Open", olDateTime
.Add "Show Close", olDateTime
.Add "Dealer Clear", olDateTime
.Add "XXX Clear", olDateTime
End With

With newAppt
.UserProperties(1) = "TEST SHOW NAME"
.UserProperties(2) = "999999"
.UserProperties(3) = "DISNEY'S GRAND FLORIDIAN"
.UserProperties(4) = "Fantasia Ballroom"
.UserProperties(5) = "Blue"
.UserProperties(6) = "Green"
.UserProperties(7) = "No Package"
.UserProperties(8) = "AE"
.UserProperties(9) = "DF" 'CRAP OUT POINT
.UserProperties(10) = "FF"
.UserProperties(11) = "MIS"
.UserProperties(12) = "SS"
.UserProperties(13) = "ESIR"
.UserProperties(14) = "ESSR"
.UserProperties(15) = "10/01/2006 8:00 AM"
.UserProperties(16) = "10/01/2006 8:00 PM"
.UserProperties(17) = "10/02/2006 9:00 AM"
.UserProperties(18) = "10/02/2006 9:00 PM"
.UserProperties(19) = "10/03/2006 10:00 AM"
.UserProperties(20) = "10/03/2006 10:00 PM"
.UserProperties(21) = "2006 11 November"
.UserProperties(22) = "11/1/2006 8:00 AM"
.UserProperties(23) = "11/2/2006 8:01 AM"
.UserProperties(24) = "12/30/2006 10:00 PM"
.UserProperties(25) = "12/31/2006 11:59 PM"
.Save
End With

Set targetFolder = Nothing
Set nms = Nothing
Set newAppt = Nothing
Set objOutlook = Nothing

End Sub


 




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
Lost data in user defined fields after performing an import Eddie Outlook - Using Forms 1 November 7th 06 06:13 PM
Can I map to user-defined fields when I import an address list? stephanienyc Outlook - Using Contacts 1 September 19th 06 03:16 PM
printing custom forms with user defined and standard fields emerald Outlook and VBA 1 July 31st 06 01:31 PM
Outlook 2003 Custom Forms User Defined Fields [email protected] Outlook and VBA 4 April 13th 06 02:50 AM
Making a custom form the default and mapping user-defined fields Mark Outlook - Using Forms 3 April 6th 06 05:18 PM


All times are GMT +1. The time now is 09:17 AM.


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.