Capture right-click'd text on Outlook Message Content - vba

I'd like to know if it's possible to capture the text when a user right-click's on an Outlook message, and then add items to the right-click menu depending on the type of text.
This is an example of what I'd like to do. If there's a message (mail item) with the following content: "Hello, please call me at 555-8474 regarding item A1234" and the user right-click's on the number "8", the pop-up context menu will have an extra item at the bottom called "Call 555-8474", and a "PhoneCall" sub will be run if selected. If the user right-click's anywhere on "A1234" a different item (i.e. "Look up A1234") will be shown.
We're running Outlook 2003 and if possible I'd like to know if this can be done using VBA. I'm open to other ideas as well. Thanks!

You can use this example in VBA to get started

SmartTags is an Office 2003 feature that was designed for exactly this sort of thing. I honestly don't know SmartTags well enough to do more than wave in the general direction, so I hope you get a better answer from a domain expert....

Related

How to programmably select elements of a Word document and copy to Excel

Is there a way to get some sort of collection of "paragraphs, images, headings1, headings2" and other "word elements" with a VBA function call. I was looking into this, I ran accros ActiveDocument.fields, but it doesn't seem to be it.
What I need to do is copy these elements, one by one, into an excel document, but I do not know how to access them in the first place. Is there any collection or what would be the syntax for accessing these. My idea is to make a loop and use it there, I could be going about this wrong.
In Word:
Hit Alt+F11 to get the VB editor.
Hit F2 to get the Object Browser.
Type "Document" into the search box and hit Enter.
Click on the row that says "Word" under Library and "Document" under Class.
In the "Members of 'Document'" list you will see all sorts of goodies! That includes things like Document.Paragraphs :) . You can then search on MSDN for details of how to use the listed fields. Prepare for lots of searching and reading online!
Once you have found the fields you are interested in, you will be able to try some things. Once you have code that almost works, but not quite, you will be ready to post detailed questions here asking for further help. See the SO tour for more on that process.

VBA to generate a default file name when Save As is selected in Word 2016

I have VBA that, in Word 2010, will default a file name into the Save As screen when the user selects the Save As file option. Word 2016 (Office 365) has a different interface with a screen to select a save location (OneDrive, This PC,etc) prior to the "standard" Save As dialog box appearing which seems to have broken the code to generate a specified default file name.
The code (with title simplified) is
Sub FileSaveAs()
With Dialogs(wdDialogFileSaveAs)
.Name = "MyTitle"
.Show
End With
End Sub
If I run the code in Developer to Debug, it works fine, with the Save As screen appearing and the file name defaulting but it does not work in the live environment where the file name defaults to the previous document name.
Based on web research, I have tried additional code to change the properties of the document place the name in the title as this is supposed to then default when Save As is selected but that also doesn't work.
Any suggestions or recommendations on how to resolve this would be appreciated.
Thanks!
Update 1/11/16:
Have been able to get a little closer by using the following:
Application.DocumentBeforeSave Event
example here https://msdn.microsoft.com/en-us/library/office/ff838299.aspx
tied to Using Events with Application Object
example here https://msdn.microsoft.com/en-us/library/office/ff821218.aspx
Had to add
Cancel=True
to the end of the event procedure code or the Save as Dialog box will open twice.
Still a bit clunky and seems to be limited to run only before the first user generated save event but almost workable.
Wanted to share what I found in case it helps others but any other suggestions for improvement would be appreciated as it still doesn't seem like the best solution.
Thanks again!
Thanks for reporting this. I have a potential workaround that I hope will help.
Could you use the SendKeys method (https://msdn.microsoft.com/en-us/library/office/gg278655.aspx) to send the keyboard shortcut (F12 for the Save As dialog, full list: http://aka.ms/Tf6yv0) to the application e.g.
App.SendKeys("{F12}")
when you need the Save As dialog to be displayed?
I hope this helps. Thanks again for bringing this issue to our attention, we will be looking further into the root cause.

Text selected / right click event (Outlook 2007 VBA)

I'm looking for an event that's raised when a user selects text in the preview pane of an email. E.g. you're viewing an email in the preview pane and select some text. I didn't see anything in the object reference to this effect, but the namespace is so large, it seems like there's always some object somewhere that does exactly what I need, which I'm not aware of.
Overall, what I'd like to do is see if the selected text matches a pattern and if so, insert a sub-menu in the right click menu (the one that says Copy, Who Is, Synonyms, Translate..). Help with this would be appreciated too. I believe the CommandBar is "text", but I'm unsure how to go about accessing this via name.
The Outlook object model doesn't provide anything for that.

Textbox dropdown bubble when text goes over visual space?

I looking for a way to add what would look like a drop down box when the user reaches the end of the visible space of a textbox. the drop down would then show what they have already typed pulse what there still typing tell they hit enter. Any ideas? The bigger pitcher is to add whatever method we come up with to a GridViewTextbox where space is limited in a row however the data they enter can be much longer then the box. The idea is to keep user from getting lost in what there typing and can provide easy review and edit. something like this but pops up when you enters then gos back on leave but just be for text as 'enter' will move the user to the next control aka enter as tab
It won't let me post the image I was talking about so use this like as a refrence .NET 2010 custom control, multiline String property to be edited in the designer
In the ASP.NET there is control which suits the need.I hope it helps
It is
<asp:AutoCompleteExtender
runat="server"
BehaviorID="AutoCompleteEx"
ID="autoComplete1"
TargetControlID="targetID"
ServicePath="Give the Path of the web service"
ServiceMethod="Name of the ID "
MinimumPrefixLength="1"
CompletionInterval="500"
EnableCaching="true"
CompletionSetCount="10"
DelimiterCharacters=";, :"
ShowOnlyCurrentWordInCompletionListItem="true"
/>
You could also use a ToolTip control to show a popup message to the user. I've read your question three times now and I'm still not sure entirely what it is you're asking.

Using VSTO to perform an action via selected e-mail text in Outlook

This should be pretty a pretty common scenario, but I have not found a solution yet.
I would like to highlight some text within the body of an e-mail and then click on something (context menu, toolbar button, etc) to perform a URL navigation using the selected text. For example, highlight the Fex Ex tracking number and then navigate to their web site using it as a query parameter (like "ww.fedextracking.com?packageid=12345").
How can you capture the selected text within an e-mail and then perform an action? I would greatly appreciate any suggestions or examples.
Thank you!
For Outlook 2007-2010 (or previous versions using WordMail), you can retrieve a Word object from the Inspector.WordEditor property. Then you can work with Word.Selection to access the selected text.
However, for Plain Text or Rich Text scenarios with Outlook 2000-2003, you have to use the SafeInspector object with Redemption (http://www.dimastr.com/redemption/) to access the selected text. I can't remember, but for HTML format messages with Outlook 2003-2003 you may be able to access the selected text with the IHTMLDocument object retrieved from SafeInspector.
I appreciate it's 588 days since you asked your question Loki70, but if somebody else Googles up this page (like I did, looking for how to create a selected text right-click context menu entry) then this may be an answer for you.
I have been using AutoHotKey, which works not just in Outlook, but everywhere in Windows, and have been writing utilities to Google the selected text, open an SSH session in PuTTY to the selected hostname, and similar.
If you don't mind running an extra application on your PC to capture the hotkey combination that you send, then this would do exactly what you're asking.
Here is my post on the AutoHotKey forum with a link to my code:
http://www.autohotkey.com/community/viewtopic.php?t=86402
It would be trivial to adapt this to do the FedEx query you've mentioned.
I hope this helps.