C
callevib
Hallo
Stil working with customising a contact form. I have added a custom field to
my form and i have publiced the form in an public folder. It words so far.
But i can not read the user field with VBA. I use the following code:
Public Sub ReturnOlKontakt()
Set olMAPI = GetObject("", "Outlook.Application").GetNameSpace("MAPI")
Set KontakterItems = olMAPI.GetDefaultFolder(olFolderContacts).Items
Dim Item
Dim myKontakt As String
' A person is choised in Userform1.ComboBox1
myKontakt = Userform1.ComboBox1.Text
For i = 1 To KontaktCount
If myArray(i, 1) = myKontakt Then
Item = myArray(i, 2)
Exit For
End If
Next i
If Not Item = 0 Then
Debug.Print KontakterItems(Item).JobTitle
Debug.Print KontakterItems(Item).FullName
Debug.Print KontakterItems(Item).CompanyName
Debug.Print KontakterItems(Item).BusinessAddressStreet
' My custom field "Gadeadresse2"
Debug.Print KontakterItems(Item).gadeadresse2
Debug.Print KontakterItems(Item).BusinessAddressPostalCode
Debug.Print KontakterItems(Item).BusinessAddressCity
Debug.Print "Kontoradressen"
End If
Set olMAPI = Nothing
Set KontakterItems = Nothing
End Sub
Can anyone tell me what is wrong???
Thanks
Stil working with customising a contact form. I have added a custom field to
my form and i have publiced the form in an public folder. It words so far.
But i can not read the user field with VBA. I use the following code:
Public Sub ReturnOlKontakt()
Set olMAPI = GetObject("", "Outlook.Application").GetNameSpace("MAPI")
Set KontakterItems = olMAPI.GetDefaultFolder(olFolderContacts).Items
Dim Item
Dim myKontakt As String
' A person is choised in Userform1.ComboBox1
myKontakt = Userform1.ComboBox1.Text
For i = 1 To KontaktCount
If myArray(i, 1) = myKontakt Then
Item = myArray(i, 2)
Exit For
End If
Next i
If Not Item = 0 Then
Debug.Print KontakterItems(Item).JobTitle
Debug.Print KontakterItems(Item).FullName
Debug.Print KontakterItems(Item).CompanyName
Debug.Print KontakterItems(Item).BusinessAddressStreet
' My custom field "Gadeadresse2"
Debug.Print KontakterItems(Item).gadeadresse2
Debug.Print KontakterItems(Item).BusinessAddressPostalCode
Debug.Print KontakterItems(Item).BusinessAddressCity
Debug.Print "Kontoradressen"
End If
Set olMAPI = Nothing
Set KontakterItems = Nothing
End Sub
Can anyone tell me what is wrong???
Thanks