Outlook Macro to Contact

Status
Not open for further replies.
Rather than paste it into a macro "hard coded", you should get the value in a string and use the string. Oh, but that means you need to select the contact first, which defeats the purpose of the macro. :( On the other hand, sometimes macros make more work when using features like instant search would more efficient than making a macro for one person.
 
thanks for your thoughts.....this would be more than I need to do....just found the way to create the macro to the contact after finding the the entryid of the contact...and then created that other macro as a string of each macro to a contact and how they then show up in the combobox of the Userform as a droplist of contacts that I then created the OutlookSession macro that runs teh macro re userform, and then added to the contact form in the script the run the macro from the OutlookSession (running the macro/userform combobox), and it runs from the form of the contact as a commandbutton.....so other than the brief having to do it twice to get the entryid, thats all I need to simply finalize a list of contacts that I want to have as droplist in the form of contacts..etct.....so, seems like nothing else to do....thank you very much for looking into it all:)
 
Also, anyway with a userform to drag a note field/box instead of a tex box? Or is there a code to add to the userform that upgrades it to copy using the mouse?
 
I looked and didn't see a note field in the control toolbox.
 
the field name of a note in a contact is "DocSiteControl" and that showsup in the control toolbox, but for some reason I can't drag it to the userform.....any thoughts on that?
 
Only Forms 2 controls are supported in userforms.

ETA: or 3rd party controls designed for userforms - but they need to support Forms 2.
 
so nothing to do.....got it!!! and no code for userform with the textbox that opens it up for the copy and paste from a mouse? correct?
 
The last code sample can copy to the clipboard - http://www.slipstick.com/developer/code-samples/paste-clipboard-contents-vba/ - but it's coming up as non-printable text.

Code:
Public lstNum21 As Long
Public Sub GetEntryIDContact2()
UserForm19.Show
Dim Session As Outlook.NameSpace
Dim currentExplorer As Explorer
Dim Selection As Selection
Dim currentItem As Object
Dim currentContact As ContactItem
Dim entryID As String 
 
Dim DataObj As MSForms.DataObject
Set currentExplorer = Application.ActiveExplorer
Set Selection = currentExplorer.Selection
'for all items do...
For Each currentItem In Selection
If currentItem.Class = olContact Then
Set currentContact = currentItem
Set DataObj = New MSForms.DataObject 
 
entryID = currentContact.entryID 
 
DataObj.SetText entryID 
 
DataObj.PutInClipboard 
 
UserForm1.TextBox19.Value = entryID
End If
Next
End Sub

if you are just doing this to get the entryid to use in a macro, remove the userform and use

entryID = currentContact.entryID

Debug.Print entryID & " Full name:" & currentContact.FullName

This prints the entryID and the contact name to the immediate window, so it's easy to copy into the code you're working with.

Select a group of contacts, run the macro then use then copy the text from the immediate window (Ctrl+G or the View menu > Immediate).
 
To use the immediate window, you only need this code -

Code:
Public Sub GetEntryIDContact2()
Dim currentExplorer As Explorer
Dim Selection As Selection
Dim currentItem As Object
Dim currentContact As ContactItem
Dim entryID As String
Set currentExplorer = Application.ActiveExplorer
Set Selection = currentExplorer.Selection
'for all items do...
For Each currentItem In Selection
If currentItem.Class = olContact Then
Set currentContact = currentItem
Set DataObj = New MSForms.DataObject 
 
entryID = currentContact.entryID 
 
Debug.Print entryID & " Full name:" & currentContact.FullName
End If
Next
End Sub
 
Thanks. Can you show me the full code with your changes as not clear what I completely do.
 
The last code sample i posted is complete - paste it in the module then Ctrl+G to show the immediate window then run the macro. You'll get a list of entry id & contact names, one for each selected contact.
 
I pasted the following macro to a module.....but Ctrl + G is not doing anything....and when opened a contact and ran the macro, nothing happened....what am I missing please?

Public Sub GetEntryIDContact2()
Dim currentExplorer As Explorer
Dim Selection As Selection
Dim currentItem As Object
Dim currentContact As ContactItem
Dim entryID As String
Set currentExplorer = Application.ActiveExplorer
Set Selection = currentExplorer.Selection
'for all items do...
For Each currentItem In Selection
If currentItem.Class = olContact Then
Set currentContact = currentItem
Set DataObj = New MSForms.DataObject

entryID = currentContact.entryID

Debug.Print entryID & " Full name:" & currentContact.FullName
End If
Next
End Sub
 
Try selecting several contacts and running it, instead of using it on an open contact.

ActiveExplorer is for selected items - it will usually still work if you open an item because the open item is still selected and focus drops back to it. But you may be doing something a little different than I am that causes the open item to remain infocus.
 
Update: Two Questions: I opened the module that has macro you gave me....with the module open, I did Ctrl + G and the "immediate" shows below with entryid and name, but not a contact that I had most recently opened or highlighted.....so how do have it show the contacts I want? thanks so much....and also, is there a shortcut to open the module??
 
Here is what I did.....I highlighted four contacts, ran the macro...opened up the module of the macro, did Ctrl + G and it shows them....great!!! I also open one contact....ran the macro....did Ctrl +G and then when I opened the module of the macro, it shows it ...........great!! So is there an easy way after I highlight the contract or open the contact, run the macro, do Ctrl + G is there a shortcut to open the module and see the immediate? or just see the immediate from that module that ran the macro??? that would be fast!!!
 
Next Update: Did what I said above, and then did the shortcut Alt + F11.....and that opens the VBA and shows the immediate....so is there a way to only show the immediate....not the module and the macros etc.?
 
Alt+F11 should pop you over into the vba editor - once the immediate window is open you don't need ctrl+g again.
 
I did it right before you told me!!! See above.....but.........so is there a way to only show the immediate like a box....not the module and the macros etc.?


 
Actually...don't need to just see the immediate...as what shows up in it is what I need to put into the macros re the links to the contact....so if I simply open up the module that has the macros to the contacts, I can quickly copy and paste the entryid to the code line ....so thanks so so much again!!!
 
Finally, the lightbulb turns on. LOL Once I understood what you were trying to do, it made more sense to get the values this way and that is why i added the names to it. You can select all, run the code, and use the correct entryid's for the correct contact. It's actually a pretty nifty code sample for collecting a lot of entry id's.
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
L Outlook 2007 Macro to Contact From a Field Using Outlook 3
L Outlook 2007 Macro Save Contact Using Outlook 10
L Outlook 2007 Macro Open Contact Folder Using Outlook 7
L Outlook 2007 Macro to Run a Script From a Contact Form Using Outlook 41
L Outlook 2007 Macro to Add Text to a Contact Field Using Outlook 10
X Custom icon (not from Office 365) for a macro in Outlook Outlook VBA and Custom Forms 1
C Outlook - Macro to block senders domain - Macro Fix Outlook VBA and Custom Forms 1
J Outlook 365 Outlook Macro to Sort emails by column "Received" to view the latest email received Outlook VBA and Custom Forms 0
M Outlook Macro to save as Email with a file name format : Date_Timestamp_Sender initial_Email subject Outlook VBA and Custom Forms 0
D Outlook 2016 Creating an outlook Macro to select and approve Outlook VBA and Custom Forms 0
S Outlook Macro for [Date][Subject] Using Outlook 1
E Outlook - Macro - send list of Tasks which are not finished Outlook VBA and Custom Forms 3
S Macro for Loop through outlook unread emails Outlook VBA and Custom Forms 2
Witzker Macro to move @domain.xx of a Spammail to Blacklist in Outlook 2019 Outlook VBA and Custom Forms 7
S Macro for other actions - Outlook 2007 Outlook VBA and Custom Forms 23
S Macro to move “Re:” & “FWD:” email recieved the shared inbox to a subfolder in outlook Outlook VBA and Custom Forms 0
S Outlook Macro to send auto acknowledge mail only to new mails received to a specific shared inbox Outlook VBA and Custom Forms 0
S Outlook Macro to move reply mail based on the key word in the subjectline Outlook VBA and Custom Forms 0
M Outlook macro to automate search and forward process Outlook VBA and Custom Forms 6
R Macro Schedule every day in Outlook Using Outlook 0
L Moving emails with similar subject and find the timings between the emails using outlook VBA macro Outlook VBA and Custom Forms 1
N How can I increase/faster outlook VBA Macro Speed ? Using Outlook 2
A Outlook macro to create search folder with mail categories as criteria Outlook VBA and Custom Forms 3
V Outlook Macro to show Flagged messages Outlook VBA and Custom Forms 2
J Help Please!!! Outlook 2016 - VBA Macro for replying with attachment in meeting invite Outlook VBA and Custom Forms 9
S Macro using .SendUsingAccount only works the first time, after starting Outlook Outlook VBA and Custom Forms 4
M Slow VBA macro in Outlook Outlook VBA and Custom Forms 5
A Forward Outlook Email by Filtering using Macro Rule Outlook VBA and Custom Forms 44
Tanja Östrand Outlook 2016 - Create Macro button to add text in Subject Outlook VBA and Custom Forms 1
D Outlook macro with today's date in subject and paste clipboard in body Outlook VBA and Custom Forms 1
C Outlook Subject Line Macro Outlook VBA and Custom Forms 0
D Macro sending outlook template from Excel list Outlook VBA and Custom Forms 6
P Macro to attach a file in a shared Outlook draft folder Outlook VBA and Custom Forms 2
R Macro to check file name with outlook address book Outlook VBA and Custom Forms 0
Diane Poremsky Use a macro to copy data in Outlook email to Excel workbook Using Outlook 0
W macro to export outlook emails to excel Outlook VBA and Custom Forms 6
J Outlook Macro to Update Sharepoint Excel File Using Outlook 1
Patrick van Berkel Best way to share (and keep up-to-date) Macro's in Outlook 2010 Outlook VBA and Custom Forms 6
C Newbie needs help with Outlook Macro Outlook VBA and Custom Forms 3
L Outlook 2007 - Macro Re Search Using Outlook 16
A newb outlook macro help Outlook VBA and Custom Forms 1
Diane Poremsky Macro to Bulk Import Contacts and vCards into Outlook Using Outlook 0
S Outlook 7 VBA macro for multiple filing Outlook VBA and Custom Forms 1
S Macro in an excel for outlook. Outlook VBA and Custom Forms 2
A Outlook Macro Causing Excel Error Outlook VBA and Custom Forms 0
Diane Poremsky Use a macro to copy data in Outlook email to Excel workbook Using Outlook 0
S Outlook Macro Reply to a message Outlook VBA and Custom Forms 1
Diane Poremsky Macro to Bulk Import vCards into Outlook Using Outlook 0
M Outlook VBA Macro that could retrieve/display the (From, Subject, Date Received) Outlook VBA and Custom Forms 2
Philip Rose Recreating a WORD Editing Macro to use in Outlook VBA Outlook VBA and Custom Forms 4

Similar threads

Back
Top