Word VBA: Where is the insertion point in a Textbox?

Posted on 2011-10-19
Last Modified: 2012-06-27
I have a textbox and need to know the current location of the insertion point in the text so that I can check the character to the immediate left of the insertion point. I will be getting this information inside a KeyPress Sub. If possible, I would like to know the location as the number of characters between the current location and the start of the text.
Thanks for any help.
Question by:JohnRobinAllen
    LVL 76

    Accepted Solution

    There is a SelStart property that tells you where the beginning of the selection is. You might also find the SelLength and the SelText properties useful.

    Author Closing Comment

    The answer came so quickly that I have not had a chance to test it. However, since it comes from Graham Skan, I know that the solution will be correct.
        Many thanks

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    A few years ago I was very much a beginner at VBA, and that very much remains the case today.  I'll do my best to explain things as I go in the hope that other beginners can follow.  If you just want to check out a tool that creates a Select Case fu…
    This article describes how to use the Send to Mail Recipient command. The instructions apply generally to Office 2007 and later versions, but Microsoft® Word 2013 was used for the specific steps and figures.  What is Send to Mail Recipient? Send…
    This video teaches the viewer how to align pictures around text while keeping the text properly aligned in the document.
    This video walks the viewer through the process of creating Hyperlinks for the web and other documents. Select the "Insert" tab: Click "Hyperlink":  Type "http://" followed by a web address to reference a website or navigate to a document to ref…

    755 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

    23 Experts available now in Live!

    Get 1:1 Help Now