Reading "Higlighted Text" in all MS Office Products

Add-in Express™ Support Service
That's what is more important than anything else

Reading "Higlighted Text" in all MS Office Products
 
George Spears




Posts: 70
Joined: 2010-05-06
Andrei,

That is the whole issue I am trying to solve. I need the user to be able to select a portion of text in an email (having just read it, not artificially having to put it in a reply window to access it). Assume you send me an email that mentions a company name. I receive it, but want to find out more about the company. That is the purpose of my plugin. I read your email, I "select/highlight" the company name (just as if I was going to Copy/paste it somewhere. I then hit a menu option which calls my code. It determines the data that the user has selected (aka the Company name) and processes it.

Question 1: Is there a way to read this selected text without having to artificially put it in an email reply?

Question 2: In the code in my previous post, I had NOT hit the reply button. Without hitting reply, I get an AV because ActiveExplorer is nil. If I hit 'reply' and then run the above code, I get the error "EIntfCastError: Interface not supported."

Could you provide a code sample (for VCL) that will read selected text, in a preview pane, without having to artificially hit the 'Reply' button?

Thanks
George S
Posted 09 Jul, 2015 07:00:59 Top
Andrei Smolin


Add-in Express team


Posts: 14094
Joined: 2006-05-11
Hello George,

I'm sorry, I mistakenly assumed you talk about selection in an email being edited. That was my fault.

No such code sample exists.

I've tested the following approach in VBA:
- get selected email
- call MailItem.GetInspector
- call Inspector.WordEditor (this return a Word.Document)
- call Document.Application.Selection
- parse the selection

Note that if the selected item is opened in an inspector and the inspector is the active window, MailItem.GetInspector returns that inspector. However, if the explorer is active, GetInspector returns ... well, I can't tell what it returns but the result is also an Inspector; calling Inspector.WordEditor.Document.Application.Selection for that "inspector" returns the selection in the Reading Pane. This "inspector" isn't deleted from the Application.Inspectors collection if you release it; I think you need to close it.

George Spears writes:
Question 2: In the code in my previous post, I had NOT hit the reply button. Without hitting reply, I get an AV because ActiveExplorer is nil.


In what event do you invoke this code? For me, it works okay in the Click event of a Ribbon button.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 09 Jul, 2015 09:35:29 Top