Run a VB macro on text selected in the outlook preview pane

Posted on 2006-03-22
Last Modified: 2012-08-13

I want to write a vb macro that creates a new email from text i have selected in the preview pane (olPreview i think) however I am pretty new to outlook. How can I co about getting the selected text into a string so that i can then generate a new email from this text (I have generated emails before).

Any advice or pointers would be great.


Question by:hallz

    Author Comment

    Note: I think it is actually called the 'Reading Pane' - the thing i need data from is the reading pane which sits under your list of emails in outlook.
    LVL 76

    Accepted Solution

    Hi hallz,

    I know of no way to get the selected text from the Reading pane.  If you want to get the selected text from the current message window and are willing to use Redemption, then this will do the trick:


    Author Comment

    The closest thing I have found is this

    There is probably some way to access the selection higher up somewhere in the api's, but this will be sufficient for my project.

    Thanks for posting.
    LVL 76

    Expert Comment

    by:David Lee

    The material in that link isn't even close to what you indicated you were looking for.  That code is for getting the currently selected item (e.g. message, contact, appointment, etc.) in a list of items.  It has nothing at all to do with returning text selected in the reading pane or the body of the message.  Did I misunderstand what you were looking for?

    Author Comment

    Hi BlueDevilFan,

    I think you understood, I am simply writing a script to process a section of an email message, selected text would have been more convenient but as the message content is system generated I can find the information with some code and process from there.

    Thanks for your Help,


    Featured Post

    Live: Real-Time Solutions, Start Here

    Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

    Join & Write a Comment

    When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
    You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
    Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now