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
Comments
-
That is the correct interpretation the speech marks are wrong for all letters
0 -
I should have said word - I will try that tomorrow.
0 -
I asked Google to create VBA macro for MS Word… again, this looks plausible but I have not tested it.
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 ' Changes the lowercase letter (the second captured group) to uppercase rng.Words(1).Characters(2).Case = wdUpperCase ' Collapse range to move past the current match rng.Collapse wdCollapseEnd Loop End With MsgBox "Finished converting text after quotation marks to uppercase.", vbInformation End Sub1 -
How is your VBA going to understand the context of the quote to know if it should be capitalised (ie its a complete quote) or should not be capitalised (ie its a partial quote)?
2 -
I think the OP wants them all converted, and then will fix any oddities manually.
1 -
Thank you, for some reason the search doesn't work, if you have a minute please can you help?
0 -
Thank you I got this message
This is the problem line any ideas please?
rng.Words(1).Characters(2).Case = wdUpperCase
0 -
Seems like AI coding has limits. Weirdly, Google knows that line is incorrect in isolation.
It suggests this as an alternative (substitute for the line in error). Unfortunately, I do not have MS Word to be able to test it.
Dim ch As Range
Set ch = rng.Words(1).Characters(2)
ch.Text = UCase(ch.Text)1 -
The entire macro with the amendment suggested…
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
' Changes the lowercase letter (the second captured group) to uppercase
Dim ch As Range
Set ch = rng.Words(1).Characters(2)
ch.Text = UCase(ch.Text)
' Collapse range to move past the current match
rng.Collapse wdCollapseEnd
Loop
End With
MsgBox "Finished converting text after quotation marks to uppercase.", vbInformation
End Sub1 -
Firstly thank you very much I still get these errors (I will try your google idea I just need to clear my account)
0
Confirm your email address to Create Threads and Reply
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




