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.

📨 Have you signed up to the Forum's new Email Digest yet? Get a selection of trending threads sent straight to your inbox daily, weekly or monthly!

Change text from lower to uppercase in word FIXED

13»

Comments

  • Cornucopia
    Cornucopia Posts: 16,809
    Part of the Furniture 10,000 Posts Name Dropper Photogenic
    Forumite
    edited 31 July at 2: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 9:37PM

    Thank you so much for your help it worked.

  • wongataa
    wongataa Posts: 2,770
    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,809
    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

🚀 Getting Started

Hi new member!

Our Getting Started Guide will help you get the most out of the Forum

Categories

  • All Categories
  • 355.7K Banking & Borrowing
  • 254.9K Reduce Debt & Boost Income
  • 456.1K Spending & Discounts
  • 248.3K Work, Benefits & Business
  • 605.9K Mortgages, Homes & Bills
  • 179K Life & Family
  • 263.7K Travel & Transport
  • 1.5M Hobbies & Leisure
  • 16.2K Discuss & Feedback
  • 37.7K Read-Only Boards

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.