Reputation: 1
I get new business contacts during day and I'm keeping book about potential customers in a .csv file. I get often contacted via email and in the message the customer tells me more accurate contact details. It takes time to copy-paste every detail one by one to the .csv file. I'm quite a noobie in vba. But I think it's the best change to solve this problem.
What I'd like to do: I highlight customer's name. Let's say it's Mark. Then I click it with the secondary mouse button and choose something like "Make a new contact". Outlook creates a new contact to the address book. Then I do the same for the address and click something like "Export as an address to Mark"
After that, I use another script which export data from contacts to the .csv file. OR The details could go directly to the .csv file from the message body. I just taught that there would be some ready solutions if we export them first to the contacts.
I haven't found anything useful on this idea. I would be very grateful if someone would help me on this!
-Joonas
Upvotes: 0
Views: 644
Reputation: 66306
Where is the text highlighted? In the preview pane? Retrieve the currently selected item (Application.ActiveExplorer.Selection). Once you have MailItem object, call MailItem.GetInspector to retrieve the Inspector object, Once you have the Inspector object, you can use Inspector.WordEditor to use the Word Object Model to retrieve the selected text.
Updated: try the script below (error checking omitted for clarity)
set msg = Application.ActiveExplorer.Selection(1)
set WordEditor = msg.GetInspector.WordEditor
set Selection = WordEditor.Application.Selection
if (Selection.Type = 1) or (Selection.Type = 0) or (Selection.Type = 2) Then
setText = Selection.Text
MsgBox setText
End If
Upvotes: 1