Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
JJ JJ is offline
external usenet poster
 
Posts: 122
Default Importing data

Okay, I've asked a couple of questions and maybe I should be giving the whole
picture.

I pull data from 5 different sources and the only common data is name and
alias. 3 of these sources give me data with that stupid return character
after SOME of the fields but not all. I need to remove that character. The
clean function works but only if there is a non-readable character. If not I
get the #Value in the cell.

One of the other sources has names but not necessarily alias' and not
necessarily the name spelled correctly. (That field is user entered and I
can't get around that).

I need to combine all the data then check the names against the last source,
but not every entry may have a name in the last source so those need to be
checked against the Outlook global address list and return their alias.

I thought this would be easy. I can call the Outlook application but I
can't figure out how to look up a name and return the alias. Am I being too
optomistic about this being simple?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default Importing data

Here is some code that I use to get e-mail addresses from the global address
list. You need to reference the CDO library to use this function.

Option Explicit
Const CdoPR_EMS_AB_PROXY_ADDRESSES = &H800F101E
Const g_strMAPILogOn As String = "MS Exchange Settings"
Const g_strAddressList As String = "Global Address List"
Const g_strEMailAddressIdentifier As String = "SMTP"


Private Sub Test()

MsgBox GetEMailAddress("James Thomlinson")

End Sub


Public Function GetEMailAddress(ByVal strName As String) As String
Dim objSession As MAPI.Session
Dim objField As MAPI.Field
Dim MyAddressList As MAPI.AddressList
Dim MyAddressEntries As MAPI.AddressEntries
Dim MyEntry As MAPI.AddressEntry
Dim SomeEntry As MAPI.AddressEntry
Dim MyRecipient As MAPI.Recipient
Dim v As Variant
Dim strReturnValue As String

'Initialize Local Variables
strReturnValue = "No Address Found" 'Retrun Value if not found

' Create Session object and Logon.
Set objSession = CreateObject("MAPI.Session")
objSession.Logon (g_strMAPILogOn)

'Create the Address list from the Global Address List
Set MyAddressList = objSession.AddressLists(g_strAddressList)
If MyAddressList Is Nothing Then
MsgBox g_strAddressList & " Unavailable!", vbCritical, "Critical
Error"
Exit Function
End If

'Initialize MyAddressEntires with the entries in the Address List
Set MyAddressEntries = MyAddressList.AddressEntries

'Traverse through the entries searching for a match
For Each SomeEntry In MyAddressEntries
Set MyEntry = SomeEntry
If Trim(UCase(strName)) = Trim(UCase(MyEntry.Name)) Then
Set objField = MyEntry.Fields(CdoPR_EMS_AB_PROXY_ADDRESSES)

' PR_EMS_AB_PROXY_ADDRESSES is a multivalued property
(PT_MV_TSTRING).
' Therefore, you need to extract the individual members.
For Each v In objField.Value
If InStr(1, UCase(v), g_strEMailAddressIdentifier) Then
strReturnValue = Mid(v, 6, 256)
Exit For
End If
Next 'Next Field Value
Exit For
End If
Next 'Next Address Entry

'Return Function Value
GetEMailAddress = strReturnValue

'Housekeeping
Set objField = Nothing
Set MyAddressList = Nothing
Set MyAddressEntries = Nothing
Set MyEntry = Nothing
Set MyRecipient = Nothing
objSession.Logoff
Set objSession = Nothing

End Function

As for the extra characters and such that is parsing and it depends on the
data...

"JJ" wrote:

Okay, I've asked a couple of questions and maybe I should be giving the whole
picture.

I pull data from 5 different sources and the only common data is name and
alias. 3 of these sources give me data with that stupid return character
after SOME of the fields but not all. I need to remove that character. The
clean function works but only if there is a non-readable character. If not I
get the #Value in the cell.

One of the other sources has names but not necessarily alias' and not
necessarily the name spelled correctly. (That field is user entered and I
can't get around that).

I need to combine all the data then check the names against the last source,
but not every entry may have a name in the last source so those need to be
checked against the Outlook global address list and return their alias.

I thought this would be easy. I can call the Outlook application but I
can't figure out how to look up a name and return the alias. Am I being too
optomistic about this being simple?

  #3   Report Post  
Posted to microsoft.public.excel.programming
JJ JJ is offline
external usenet poster
 
Posts: 122
Default Importing data

Great!!!

The data is being pulled from a Lotus Notes DB and I've noticed that it
usually is just the return character. Is there a character code for it? I
can do a find replace if I can get the Chr(#), can't I?

"Jim Thomlinson" wrote:

Here is some code that I use to get e-mail addresses from the global address
list. You need to reference the CDO library to use this function.

Option Explicit
Const CdoPR_EMS_AB_PROXY_ADDRESSES = &H800F101E
Const g_strMAPILogOn As String = "MS Exchange Settings"
Const g_strAddressList As String = "Global Address List"
Const g_strEMailAddressIdentifier As String = "SMTP"


Private Sub Test()

MsgBox GetEMailAddress("James Thomlinson")

End Sub


Public Function GetEMailAddress(ByVal strName As String) As String
Dim objSession As MAPI.Session
Dim objField As MAPI.Field
Dim MyAddressList As MAPI.AddressList
Dim MyAddressEntries As MAPI.AddressEntries
Dim MyEntry As MAPI.AddressEntry
Dim SomeEntry As MAPI.AddressEntry
Dim MyRecipient As MAPI.Recipient
Dim v As Variant
Dim strReturnValue As String

'Initialize Local Variables
strReturnValue = "No Address Found" 'Retrun Value if not found

' Create Session object and Logon.
Set objSession = CreateObject("MAPI.Session")
objSession.Logon (g_strMAPILogOn)

'Create the Address list from the Global Address List
Set MyAddressList = objSession.AddressLists(g_strAddressList)
If MyAddressList Is Nothing Then
MsgBox g_strAddressList & " Unavailable!", vbCritical, "Critical
Error"
Exit Function
End If

'Initialize MyAddressEntires with the entries in the Address List
Set MyAddressEntries = MyAddressList.AddressEntries

'Traverse through the entries searching for a match
For Each SomeEntry In MyAddressEntries
Set MyEntry = SomeEntry
If Trim(UCase(strName)) = Trim(UCase(MyEntry.Name)) Then
Set objField = MyEntry.Fields(CdoPR_EMS_AB_PROXY_ADDRESSES)

' PR_EMS_AB_PROXY_ADDRESSES is a multivalued property
(PT_MV_TSTRING).
' Therefore, you need to extract the individual members.
For Each v In objField.Value
If InStr(1, UCase(v), g_strEMailAddressIdentifier) Then
strReturnValue = Mid(v, 6, 256)
Exit For
End If
Next 'Next Field Value
Exit For
End If
Next 'Next Address Entry

'Return Function Value
GetEMailAddress = strReturnValue

'Housekeeping
Set objField = Nothing
Set MyAddressList = Nothing
Set MyAddressEntries = Nothing
Set MyEntry = Nothing
Set MyRecipient = Nothing
objSession.Logoff
Set objSession = Nothing

End Function

As for the extra characters and such that is parsing and it depends on the
data...

"JJ" wrote:

Okay, I've asked a couple of questions and maybe I should be giving the whole
picture.

I pull data from 5 different sources and the only common data is name and
alias. 3 of these sources give me data with that stupid return character
after SOME of the fields but not all. I need to remove that character. The
clean function works but only if there is a non-readable character. If not I
get the #Value in the cell.

One of the other sources has names but not necessarily alias' and not
necessarily the name spelled correctly. (That field is user entered and I
can't get around that).

I need to combine all the data then check the names against the last source,
but not every entry may have a name in the last source so those need to be
checked against the Outlook global address list and return their alias.

I thought this would be easy. I can call the Outlook application but I
can't figure out how to look up a name and return the alias. Am I being too
optomistic about this being simple?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default Importing data

That should work. You just need to look up the ASCII reference.

"JJ" wrote:

Great!!!

The data is being pulled from a Lotus Notes DB and I've noticed that it
usually is just the return character. Is there a character code for it? I
can do a find replace if I can get the Chr(#), can't I?

"Jim Thomlinson" wrote:

Here is some code that I use to get e-mail addresses from the global address
list. You need to reference the CDO library to use this function.

Option Explicit
Const CdoPR_EMS_AB_PROXY_ADDRESSES = &H800F101E
Const g_strMAPILogOn As String = "MS Exchange Settings"
Const g_strAddressList As String = "Global Address List"
Const g_strEMailAddressIdentifier As String = "SMTP"


Private Sub Test()

MsgBox GetEMailAddress("James Thomlinson")

End Sub


Public Function GetEMailAddress(ByVal strName As String) As String
Dim objSession As MAPI.Session
Dim objField As MAPI.Field
Dim MyAddressList As MAPI.AddressList
Dim MyAddressEntries As MAPI.AddressEntries
Dim MyEntry As MAPI.AddressEntry
Dim SomeEntry As MAPI.AddressEntry
Dim MyRecipient As MAPI.Recipient
Dim v As Variant
Dim strReturnValue As String

'Initialize Local Variables
strReturnValue = "No Address Found" 'Retrun Value if not found

' Create Session object and Logon.
Set objSession = CreateObject("MAPI.Session")
objSession.Logon (g_strMAPILogOn)

'Create the Address list from the Global Address List
Set MyAddressList = objSession.AddressLists(g_strAddressList)
If MyAddressList Is Nothing Then
MsgBox g_strAddressList & " Unavailable!", vbCritical, "Critical
Error"
Exit Function
End If

'Initialize MyAddressEntires with the entries in the Address List
Set MyAddressEntries = MyAddressList.AddressEntries

'Traverse through the entries searching for a match
For Each SomeEntry In MyAddressEntries
Set MyEntry = SomeEntry
If Trim(UCase(strName)) = Trim(UCase(MyEntry.Name)) Then
Set objField = MyEntry.Fields(CdoPR_EMS_AB_PROXY_ADDRESSES)

' PR_EMS_AB_PROXY_ADDRESSES is a multivalued property
(PT_MV_TSTRING).
' Therefore, you need to extract the individual members.
For Each v In objField.Value
If InStr(1, UCase(v), g_strEMailAddressIdentifier) Then
strReturnValue = Mid(v, 6, 256)
Exit For
End If
Next 'Next Field Value
Exit For
End If
Next 'Next Address Entry

'Return Function Value
GetEMailAddress = strReturnValue

'Housekeeping
Set objField = Nothing
Set MyAddressList = Nothing
Set MyAddressEntries = Nothing
Set MyEntry = Nothing
Set MyRecipient = Nothing
objSession.Logoff
Set objSession = Nothing

End Function

As for the extra characters and such that is parsing and it depends on the
data...

"JJ" wrote:

Okay, I've asked a couple of questions and maybe I should be giving the whole
picture.

I pull data from 5 different sources and the only common data is name and
alias. 3 of these sources give me data with that stupid return character
after SOME of the fields but not all. I need to remove that character. The
clean function works but only if there is a non-readable character. If not I
get the #Value in the cell.

One of the other sources has names but not necessarily alias' and not
necessarily the name spelled correctly. (That field is user entered and I
can't get around that).

I need to combine all the data then check the names against the last source,
but not every entry may have a name in the last source so those need to be
checked against the Outlook global address list and return their alias.

I thought this would be easy. I can call the Outlook application but I
can't figure out how to look up a name and return the alias. Am I being too
optomistic about this being simple?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Missing Cloumn data when importing external data Findus Excel Discussion (Misc queries) 0 December 16th 08 11:22 AM
Importing:Data Connection Wizard Doesn't see Source Data - No Impo Exotic Hadron Excel Discussion (Misc queries) 0 October 1st 08 07:35 PM
Removing Data Tables formed from importing data from Access Andrea Jones Excel Discussion (Misc queries) 0 April 10th 08 12:01 PM
Data types when importing Excel data to SQLServer [email protected] Excel Discussion (Misc queries) 1 September 27th 06 12:48 PM
Importing data, then adding data to the new spreadsheet.. a conund AndyL82 Excel Discussion (Misc queries) 1 March 9th 06 10:05 PM


All times are GMT +1. The time now is 12:10 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"