UserForm Code For Contact Links

Status
Not open for further replies.

LMS

Senior Member
Outlook version
Email Account
Exchange Server
To the Smart Woman!!! Did you get my last e-mail explaining how it searches the contact folder but shows up the names on duplicated bases...meaning...many many times.....can you look at the code I sent by e-mail and let me know what to do please...as it does do the search.....
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
i haven't had a chance t look at it, looking into problems with a bad update.
 

LMS

Senior Member
Outlook version
Email Account
Exchange Server
Mine is a bad update or something else you are working on?

For me, its where to put the following:

Set myContacts = objFolder.Items.Restrict("[Categories] = '" & Category & "'")

Set ctcItems = objFolder.Items.Restrict("[FullName] = '" & ContactName & "'")

As Set objFolder = objOutlook.Session.GetDefaultFolder(OlDefaultFolders.olFolderContacts) is already in both places of the code
 

LMS

Senior Member
Outlook version
Email Account
Exchange Server
I emailed you the updated code as I found the way to put in the two lines above and not repeating the contacts....and still links to the contacts as well...and searches all folders, subfolders, sub-sub folders, and sub-sub-subfolders....

Thanks so much as your words originally Set myContacts = objFolder.Items.Restrict("[Categories] = '" & Category & "'") I then used the the objfolder.items.restrict concept for the contact link area as well....

So just now need how to sort the comboboxes on an alphebetical way and not sorted just from each folder or subfolder they come from!!
 

LMS

Senior Member
Outlook version
Email Account
Exchange Server
Thru online Outlook Exchange, they say that the following code will load a ComboBox with sorted data from a Contacts folder.....

So, can you look at this, and see what if we can updgrade relative to both Comboboxes per my code, and where do I add it to the Code so it does it??

Function Item_Open()
Set Mypage = Item.GetInspector.ModifiedFormPages("Message")
Set MyFolder = Application.GetNameSpace("MAPI").GetDefaultFolder(10)
Set MyContacts = MyFolder.Items
Set MyItem = MyContacts.Item(1)
Set ComboBox1 = GetInspector.ModifiedFormPages("Message").Controls("ComboBox1")
ComboBox1.Clear
MyContacts.Sort"[LastName]",False
ReDim MyArray(MyContacts.Count - 1,3)
Dim I
I=0

For Each MyItem In MyContacts

Debug.WriteLine(MyItem.LastName & " " & MyItem.CompanyName & " " & MyItem.FileAs)
' ComboBox1.AddITem MyItem.FirstName & " " & MyItem.LastName, 0
MyArray(I, 0) = MyItem.FirstName & " " & MyItem.LastName & " " &
MyItem.CompanyName
MyArray(I, 1) = MyItem.CompanyName
MyArray(I, 2) = MyItem.FileAS
I=I+1
Next

'Set Combobox equal to the array to populate list
ComboBox1.List() = MyArray
End Function
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Does that code get contacts from all of your folders or just one?
 

LMS

Senior Member
Outlook version
Email Account
Exchange Server
Ast to the code I use to show the categories and related contacts, it searches the contact folder and all subfolders, sub-subfolders and sub-sub -subfolders. As to the code that I just posted, I don't know what it is.

Waiting on the Smart Woman!!!
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Only dumb women around here tonight. ;) I'll take a look at it as soon as I get my newsletter sent - the bad Outlook 2013 updates have me behind schedule.
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
This code:




ReDim MyArray(MyContacts.Count - 1,3)
Dim I
I=0
For Each MyItem In MyContacts
Debug.WriteLine(MyItem.LastName & " " & MyItem.CompanyName & " " & MyItem.FileAs)
' ComboBox1.AddITem MyItem.FirstName & " " & MyItem.LastName, 0
MyArray(I, 0) = MyItem.FirstName & " " & MyItem.LastName & " " &
MyItem.CompanyName
MyArray(I, 1) = MyItem.CompanyName
MyArray(I, 2) = MyItem.FileAS
I=I+1
Next






grabs each contact then sorts them as it reads them. you'd repeat it for each folder, building into the array.




it uses MyContacts as the variable:


Set MyFolder = Application.GetNameSpace("MAPI").GetDefaultFolder( 10)
Set MyContacts = MyFolder.Items




you'll change MyContacts to the variable you use in your code (if its not MyContacts).






BTW, I'll be out of town for the weekend.
 

LMS

Senior Member
Outlook version
Email Account
Exchange Server
Thanks. Where do i put these please re my full code And what do i change or delete re my code?? I can do what you tell me right away.
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
I think it would be here - definitely after you set myContacts. I'm not 100% sure if redimming will erase the array, you might need to delete that line, dimming it only at the top of the macro.

Set myContacts = fldr.items.Restrict("[Categories] = '" & Category & "'")
If myContacts.Count > 0 Then

ReDim MyArray(MyContacts.Count - 1,3)
Dim I
I=0
For Each MyItem In MyContacts
Debug.WriteLine(MyItem.LastName & " " & MyItem.CompanyName & " " & MyItem.FileAs)
' ComboBox1.AddITem MyItem.FirstName & " " & MyItem.LastName, 0
MyArray(I, 0) = MyItem.FirstName & " " & MyItem.LastName & " " &
MyItem.CompanyName
MyArray(I, 1) = MyItem.CompanyName
MyArray(I, 2) = MyItem.FileAS
I=I+1
Next
 

LMS

Senior Member
Outlook version
Email Account
Exchange Server
Are are there dims i put at the top? CAn you type to me the full updated code across all?
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Are are there dims i put at the top? CAn you type to me the full updated code across all?

These are the two lines that Dim - try the macro with them in the code where they are and if MyArrary only has contacts for one folder, it will need moved, although I'm not totally sure where it should be.

ReDim MyArray(MyContacts.Count - 1,3)
Dim I
 

LMS

Senior Member
Outlook version
Email Account
Exchange Server
I emailed you the entire code as whatever I tried, there were different errors.....so send it back to me based on all your changes and I will give it a try....thanks so much
 

LMS

Senior Member
Outlook version
Email Account
Exchange Server
Any possible update tonight as the full code?
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
A Outlook Userform Size Outlook VBA and Custom Forms 2
N Activity Tracking with Userform Outlook VBA and Custom Forms 4
D Next Available Meeting with Userform Variables Outlook VBA and Custom Forms 1
A Populate Excel from Outlook Userform Outlook VBA and Custom Forms 3
B Insert Hyperlinks for attachments in Userform Outlook VBA and Custom Forms 5
D Change sender name outlook vba 2010 Custom Userform Outlook VBA and Custom Forms 1
A Open CHM file from VBA Userform Outlook VBA and Custom Forms 4
L Outlook 2007 - Userform Using Outlook 2
A Focus on the userform Outlook VBA and Custom Forms 15
F Outlook 2010 - outlook userform and combo boxes Using Outlook 9
L Userform Field Month and Date. Using Outlook 19
witzker insert Date & Time (HH:mm) no (ss) in userform Using Outlook 6
A insert Date & Time in userform Using Outlook 3
X VBA: Confused with variables between ThisOutlookSession and UserForm Using Outlook 1
M Progrescreas Bar in Outlook UserForm Using Outlook 1
C UserForm and ordering variables Outlook VBA and Custom Forms 3
J userform combobox Outlook VBA and Custom Forms 1
R combobox list in userform Outlook VBA and Custom Forms 1
B Userform Outlook VBA and Custom Forms 5
W Using Excel UserForm from Open Workbook in Outlook VBA Outlook VBA and Custom Forms 5
P userform in VBAProject.otm not working Outlook VBA and Custom Forms 1
Aussie Outlook 365 Rule runs manually but returns the error code "an unexpected error has occurred" when incoming mail arrives Using Outlook 1
S Need code to allow defined starting folder and selection from there to drill down Outlook VBA and Custom Forms 10
D VBA code to select a signature from the signatures list Outlook VBA and Custom Forms 3
S HTML Code Embedded in String Within Open Outlook Email Preventing Replace(Application.ActiveInspector.CurrentItem.HTMLBody From Working Outlook VBA and Custom Forms 4
P Color Code or highlight folders in Outlook 2016 Using Outlook 2
N Please advise code received new mail Using Outlook 0
B Outlook 2016 Unable to view images or logos on the outlook 2016 emails the same html code works well when i use outlook 2010 Using Outlook 0
S Excel vba code to manage outlook web app Using Outlook 10
S Outlook VBA How to adapt this code for using in a different Mail Inbox Outlook VBA and Custom Forms 0
S Add VBA save code Using Outlook 0
C Auto Run VBA Code on new email Outlook VBA and Custom Forms 1
witzker Pls help to change the code for inserting date in Ol contact body Outlook VBA and Custom Forms 5
I Outlook 2003 shows html code when To: field is empty Using Outlook 7
F VBA code to dock Styles whenever I write or edit an email Outlook VBA and Custom Forms 0
S Skype for business meeting vba code Outlook VBA and Custom Forms 1
R Expand VBA Permanent Delete Code Outlook VBA and Custom Forms 6
B Outlook Business Contact Manager with SQL to Excel, User Defined Fields in BCM don't sync in SQL. Can I use VBA code to copy 1 field to another? BCM (Business Contact Manager) 0
A VBA Code in Outlook disappears after first use Outlook VBA and Custom Forms 1
Alex Cotton "invalid or unqualified reference" on code that should work Outlook VBA and Custom Forms 5
F VBA to ensure a code is entered in Subject title Outlook VBA and Custom Forms 1
Z Outlook Custom Form: Adding Dropdown(Project Code) at the end of subject Outlook VBA and Custom Forms 0
D Any updates or fixes that would make this code stop working just moving emails to another folder Outlook VBA and Custom Forms 1
N Open & Save VBAProject.Otm using VBA Code Outlook VBA and Custom Forms 1
M error code 0x8DE00006 Using Outlook 1
R VBA Code to permanently delete selected email Outlook VBA and Custom Forms 10
dyny723 Outlook 2016: Code to link a contact to emails received from that contact Outlook VBA and Custom Forms 1
D Command Button code will not execute. Any suggestions Please. Outlook VBA and Custom Forms 2
V VB script code to save a specific email attachment from a given email Outlook VBA and Custom Forms 14
J Custom form code doesn't run Outlook VBA and Custom Forms 2

Similar threads

Top