+ Reply to Thread
Results 1 to 9 of 9

Formatting text in textbox

  1. #1
    Forum Contributor
    Join Date
    05-08-2009
    Location
    england
    MS-Off Ver
    Excel 2007
    Posts
    223

    Formatting text in textbox

    It have a textbox in a userform that allows users to enter "free text" into it in response to a question prior to submitting it to a word document. The following code recognises where a full stop and been inserted and changes the next word into Proper Case.

    It fails to work however when a carriage return is introduced, i.e. when introducing paragraphs.

    How may this be resolved?

    Please Login or Register  to view this content.

  2. #2
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Formatting text in textbox

    If you're inserting the content directly into the document, you can use code like:
    Please Login or Register  to view this content.
    Leaving aside the question of what I'm inserting, the above code sets a range object to point to the destination (in the case, the start of the document), inserts the content, then uses Word's own tools for the sentence case conversion.
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    Forum Contributor
    Join Date
    05-08-2009
    Location
    england
    MS-Off Ver
    Excel 2007
    Posts
    223

    Re: Formatting text in textbox

    Sorry, I'm not sure what the above is all about...

    The code I displayed changes the case of the text as the user types into the box.

    I'm not sure how or where you run the code you've provided. I inserted it and as soon as I ran the userform I got a page and a half of the text located within your code.

  4. #4
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Formatting text in textbox

    Perhaps:
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    05-08-2009
    Location
    england
    MS-Off Ver
    Excel 2007
    Posts
    223

    Re: Formatting text in textbox

    The sentences appear correct up to the point where I hit enter to create a carriage return and word crashes....

  6. #6
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Formatting text in textbox

    That's sad. Try:
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    05-08-2009
    Location
    england
    MS-Off Ver
    Excel 2007
    Posts
    223

    Re: Formatting text in textbox

    Run the above and I get the error message...


    "Run time error '5': Invalid procedure call or arguement

    highlighting this this line,

    Please Login or Register  to view this content.

  8. #8
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Formatting text in textbox

    OK, have a go with this version of the Function:
    Please Login or Register  to view this content.
    Intentionally, the function does not capitalize a letter immediately after one of the nominated punctuation characters - there must be a space between them. If you need a variation on that theme let me know.

  9. #9
    Forum Contributor
    Join Date
    05-08-2009
    Location
    england
    MS-Off Ver
    Excel 2007
    Posts
    223

    Re: Formatting text in textbox

    That is absolutely spot on...exactly what I wanted...

    much appreciated,

    thank you.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1