A
Alan
Hi All,
I am trying to use VBA to change the FileAs property of all the
contacts within a given contacts folder to the Company Name for that
contact (every contact always has something in the Company Name
field).
The code I have so far is posted below (I am quite a newbie so it may
not be the most efficient, but time is not an issue - just getting it
working!)
It *seems* to work, even to the point that the unnecessary line that
reads "FileAs = .FileAs" confirms via the locals window that the
FileAs property for the item has been changed as expected.
However, once the code has run, when I return to the contact folder,
the items still have their original FileAs settings.
Any help is much appreciated.
Regards,
Alan.
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Sub FileAs_ToCompany()
Dim objNS As NameSpace
Dim FolderCollection As Folders
Dim AlanMainMailFileFolders As Folders
Dim AlanContactsFolders As Folders
Dim ImportedClientEmailAddressesItems As Items
Set objNS = Application.GetNamespace("MAPI")
Set FolderCollection = Application.GetNamespace("MAPI").Folders
Set AlanMainMailFileFolders = FolderCollection("Alan - Main Mail
File").Folders
Set AlanContactsFolders =
AlanMainMailFileFolders("Contacts").Folders
Set ImportedClientEmailAddressesItems =
AlanContactsFolders("Imported Client Email Addresses").Items
Set FolderCollection = Nothing
Set AlanMainMailFileFolders = Nothing
Set AlanContactsFolders = Nothing
Set objNS = Nothing
For Counter = 1 To ImportedClientEmailAddressesItems.Count
Set ContactItem = ImportedClientEmailAddressesItems(Counter)
Company = ContactItem.CompanyName
With ContactItem
.FileAs = Company
FileAs = .FileAs
End With
Next Counter
End Sub
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
I am trying to use VBA to change the FileAs property of all the
contacts within a given contacts folder to the Company Name for that
contact (every contact always has something in the Company Name
field).
The code I have so far is posted below (I am quite a newbie so it may
not be the most efficient, but time is not an issue - just getting it
working!)
It *seems* to work, even to the point that the unnecessary line that
reads "FileAs = .FileAs" confirms via the locals window that the
FileAs property for the item has been changed as expected.
However, once the code has run, when I return to the contact folder,
the items still have their original FileAs settings.
Any help is much appreciated.
Regards,
Alan.
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Sub FileAs_ToCompany()
Dim objNS As NameSpace
Dim FolderCollection As Folders
Dim AlanMainMailFileFolders As Folders
Dim AlanContactsFolders As Folders
Dim ImportedClientEmailAddressesItems As Items
Set objNS = Application.GetNamespace("MAPI")
Set FolderCollection = Application.GetNamespace("MAPI").Folders
Set AlanMainMailFileFolders = FolderCollection("Alan - Main Mail
File").Folders
Set AlanContactsFolders =
AlanMainMailFileFolders("Contacts").Folders
Set ImportedClientEmailAddressesItems =
AlanContactsFolders("Imported Client Email Addresses").Items
Set FolderCollection = Nothing
Set AlanMainMailFileFolders = Nothing
Set AlanContactsFolders = Nothing
Set objNS = Nothing
For Counter = 1 To ImportedClientEmailAddressesItems.Count
Set ContactItem = ImportedClientEmailAddressesItems(Counter)
Company = ContactItem.CompanyName
With ContactItem
.FileAs = Company
FileAs = .FileAs
End With
Next Counter
End Sub
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+