We’d like to remind Forumites to please avoid political debate on the Forum.

This is to keep it a safe and useful space for MoneySaving discussions. Threads that are – or become – political in nature may be removed in line with the Forum’s rules. Thank you for your understanding.

Change text from lower to uppercase in word FIXED

13»

Comments

  • Cornucopia
    Cornucopia Posts: 16,834
    Part of the Furniture 10,000 Posts Name Dropper Photogenic
    Forumite
    edited 31 July at 1:27PM

    I'm not impressed with Google on this. I don't really understand how it can give an answer it claims is correct, but then knows it's not correct when you go back and query it. And to do it twice.

    I ran the code through a VBA-specific checker, and it changed it to this:-

     Sub ConvertTextAfterQuoteToUppercase()
    Dim rng As Range

    Set rng = ActiveDocument.Content

    With rng.Find
    .ClearFormatting
    ' Finds an opening quote followed by any lowercase letter
    ' [""'‘“] covers straight and curly, single and double quotes
    .Text = "([""''‘“])([a-z])"
    .MatchWildcards = True
    .Forward = True
    .Wrap = wdFindStop

    ' Loop through all matches in the document
    Do While .Execute
    ' The matched range (rng) encompasses both characters.
    ' The second captured group ([a-z]) is the second character.
    rng.Characters(2).Text = UCase(rng.Characters(2).Text)

    ' Collapse range to move past the current match and continue searching
    rng.Collapse wdCollapseEnd
    Loop
    End With

    MsgBox "Finished converting text after quotation marks to uppercase.", vbInformation
    End Sub
  • Thomas_Holding
    Thomas_Holding Posts: 598
    Eighth Anniversary 100 Posts Name Dropper
    Forumite

    Thank you I will try that over the weekend

  • Thomas_Holding
    Thomas_Holding Posts: 598
    Eighth Anniversary 100 Posts Name Dropper
    Forumite
    edited 31 July at 8:37PM

    Thank you so much for your help it worked.

  • wongataa
    wongataa Posts: 2,774
    Part of the Furniture 1,000 Posts Name Dropper
    Forumite

    That is because LLM AI does not know anything. They are basically very fancy predictive text engines.

  • Cornucopia
    Cornucopia Posts: 16,834
    Part of the Furniture 10,000 Posts Name Dropper Photogenic
    Forumite

    It didn't predict very well. Maybe the errors in question are a consequence of older versions of the development environment or something? That's a very human error - creating a non-working program due to "remembering" the object model wrongly.

    I didn't go down the rabbit hole of asking it to syntax check its own code, but presumably there's some nugget of learning there for it to do that itself (when producing code) rather than waiting to be prompted.

★ ★ ★ Meet your Ambassadors

Categories

  • All Categories
  • 356K Banking & Borrowing
  • 255K Reduce Debt & Boost Income
  • 456.3K Spending & Discounts
  • 248.5K Work, Benefits & Business
  • 606.4K Mortgages, Homes & Bills
  • 179.1K Life & Family
  • 264.2K Travel & Transport
  • 1.6M Hobbies & Leisure
  • 16.2K Discuss & Feedback
  • 37.7K Read-Only Boards
Quick Search

Is this how you want to be seen?

We see you are using a default avatar. It takes only a few seconds to pick a picture.