none
Extracting Specific Info from textbox RRS feed

  • Question

  • Any idea on how, in Word 2013/10, I could use the AfterUpdate of a field to grab all numbers on the right of a ‘/’. I have a reference number that looks similar to this, ACH/MR/Q/12345. It is the 12345 I want to grab. Point to note it may be only 4 numbers and not the 5. I would then want just the 4. Sincerest Thanks, Toni


    Toni Chaffin aka Talisa

    Friday, October 4, 2013 9:23 AM

Answers

  • You could use code like:

    Private Sub TextBox1_AfterUpdate()
    TextBox2.Text = Split(TextBox1.Text, "/")(UBound(Split(TextBox1.Text, "/")))
    End Sub

    With this code, it really doesn't matter how many '/' separators your data have or how many characters appear after the last one.


    Cheers
    Paul Edstein
    [MS MVP - Word]

    Friday, October 4, 2013 10:23 PM

All replies

  • What is meant by "a field" or, referring to your subject line, "textbox"? There are any number of things in Word that are called by these two terms, we have to understand exactly which you are using.

    Also, which programming language are you working in? In a general way, I think you need to manipulate the string containing the information you show. This will not be something particular to Word, but to the programming language you're using.


    Cindy Meister, VSTO/Word MVP, my blog

    Friday, October 4, 2013 1:50 PM
    Moderator
  • You could use code like:

    Private Sub TextBox1_AfterUpdate()
    TextBox2.Text = Split(TextBox1.Text, "/")(UBound(Split(TextBox1.Text, "/")))
    End Sub

    With this code, it really doesn't matter how many '/' separators your data have or how many characters appear after the last one.


    Cheers
    Paul Edstein
    [MS MVP - Word]

    Friday, October 4, 2013 10:23 PM
  • Thanks Paul, I will give this a go now. Cindy, I am using VBA and I am referring to a textbox on a UserForm

    T


    Toni Chaffin aka Talisa

    Sunday, October 6, 2013 11:24 AM