UserForm Code For Contact Links

Status
Not open for further replies.
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.....
 
i haven't had a chance t look at it, looking into problems with a bad update.
 
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
 
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!!
 
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
 
Does that code get contacts from all of your folders or just one?
 
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!!!
 
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.
 
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.
 
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.
 
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
 
Are are there dims i put at the top? CAn you type to me the full updated code across all?
 
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
 
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
 
Any possible update tonight as the full code?
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
R Adding Userform Dropdown List items from names of subfolders on network drive Outlook VBA and Custom Forms 10
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
P How to get a QR code for automatic signin with Outlook for iOS Using Outlook 5
D Outlook 2021 Using vba code to delete all my spamfolders not only the default one. Outlook VBA and Custom Forms 0
F Color code certain INBOX emails Using Outlook 2
K vba code to auto download email into a specific folder in local hard disk as and when any new email arrives in Inbox/subfolder Outlook VBA and Custom Forms 0
J Want to create a button on the nav bar (module add-in) to run code Outlook VBA and Custom Forms 2
H Preventing the 'email address fetch from Exchange' crashing email reading code Exchange Server Administration 0
C Code to move mail with certain attachment name? Does Not work Outlook VBA and Custom Forms 3
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

Similar threads

Back
Top