Consulting

Page 2 of 2 FirstFirst 1 2
Results 21 to 28 of 28

Thread: Solved: How can I change text to true proper case?

  1. #21
    VBAX Newbie
    Joined
    Nov 2015
    Posts
    3
    Location
    Question: I'd like to add some exception to the Proper Code such as CEO, UNICEF, NBA, ESPN, BMW, IBM as many other acronyms. Thanks!

  2. #22
    Paul's macro indicates that it is capable of preserving capitalisation of acronyms

    If Caps = 0, then upper-case strings like ABC are preserved; otherwise they're converted.

    See also the True title case macro on my web site at http://www.gmayor.com/word_vba_examples_2.htm This too will not affect acronyms already capitalised.
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

  3. #23
    VBAX Newbie
    Joined
    Nov 2015
    Posts
    3
    Location
    Thanks for the Reply. let say

    i.e:
    1) LCell.Formula = ProperCase(LCell.Formula, 0, 0) input IBM DB2 Version For Linux, UNIX, ANd WinDOWs Will be converted to IBM DB2 Version For Linux, UNIX, ANd WinDOWs
    2) LCell.Formula = ProperCase(LCell.Formula, 1, 0) input IBM DB2 Version For Linux, UNIX, ANd WinDOWs Will be converted to Ibm Db2 Version for Linux, Unix, and Windows
    3) LCell.Formula = ProperCase(LCell.Formula, 0, 1) input IBM DB2 Version For Linux, UNIX, ANd WinDOWs Will be converted to IBM DB2 Version For Linux, UNIX, ANd WinDOWs
    4) LCell.Formula = ProperCase(LCell.Formula, 1, 1) input IBM DB2 Version For Linux, UNIX, ANd WinDOWs Will be converted to Ibm Db2 Version For Linux, Unix, And Windows

    As you can see 2 and 4 are the best options but they can not preserved acronyms on upper case. number 1 and 3 preserved all upper cases.
    I will look into the the link that you sent. once again thanks. If I find a solution I'll share it.


  4. #24
    VBAX Newbie
    Joined
    Nov 2015
    Posts
    3
    Location
    At the beginning of the function I added

    Dim StrAllCaps As String
    AcronymsCaps = 1 ' This control is not implemented yet. The idea is 0= follows the function rules 1= Acronyms on Upper-Cases as shown on StrExclCaps.
    StrExclCaps = " IBM , CEO , UNICEF , C&C , UNIX , DB2 " ' keep adding as many acronyms as many you need to check.

    At the very end of the function I added

    For i = 0 To UBound(Split(StrExclCaps, ","))
    StrTmpA = Split(StrExclCaps, ",")(i)
    StrTmpB = UCase(Left(StrTmpA, 2)) & Right(LCase(StrTmpA), Len(StrTmpA) - 2)
    StrTxt = Replace(StrTxt, Trim(StrTmpB), Trim(StrTmpA))
    Next

    ProperCase = Trim(StrTxt) ' This one is the very last sentence of the function


    Following above sample the result is what I expected, it is correct.

    LCell.Formula = ProperCase(LCell.Formula, 1, 1) input IBM DB2 Version For Linux, UNIX, ANd WinDOWs Will be converted to IBM DB2 Version For Linux, UNIX, And Windows

    Feedback is always welcome.

  5. #25
    If the input string is all in UPPERCASE then this function doesnt convert it to proper case.

    How to convert a all upper case string to proper case?
    Last edited by macropod; 05-11-2017 at 09:29 PM.

  6. #26
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Perhaps you should read what I posted in post #19, especially the comments in the first few lines of the code.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  7. #27
    If you are referring to Paul's function, then as I commented earlier, the function has a switch that will optionally preserve upper case to accommodate acronyms.
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

  8. #28
    Got it. Thanks.

Posting Permissions

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