![]() |
|
|
|
#1
|
|||
|
|||
|
Hello guys, Is there any way to create a macro to change all instances of ALL CAPS to uppercase? I tried to create it by using wildcards but there is no way to replace all instances to uppercase (not available in the wildcard menu). Thank you in advance! |
|
#2
|
|||
|
|||
|
Try this:
Backup the original file and code before doing any modification, test before use, use at your own. Quote:
|
|
#3
|
|||
|
|||
|
It works!
I will try to tweak your code to make another find/replace. Thanks so much! |
|
#4
|
||||
|
||||
|
Why do you need a macro at all to "change all instances of ALL CAPS to uppercase"? All you need do is choose 'UPPERCASE' from the 'Change Case' dropdown...
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#5
|
|||
|
|||
|
As far as I know there is no way to select the option UPPERCASE in the wildcards. Otherwise, we should change all instances one by one.
|
|
#6
|
||||
|
||||
|
Quote:
Code:
Sub Demo(): ActiveDocument.Range.Case = wdUpperCase: End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#7
|
|||
|
|||
|
Hi Macropod,
In the code above ".Collapse wdCollapseEnd" is really necessary? What it does? Thanks |
|
#8
|
||||
|
||||
|
The Collapse end is there to ensure that the previously found item is not re-found.
Instead, it moves to the end of the previously found range to continue searching forward from that point.
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
|
#9
|
|||
|
|||
|
Superb! Thank you! I was planning to remove this line, not anymore!
|
|
#10
|
|||
|
|||
|
So I understand it might have parts of the text the is is lowercase (must be in lowercase), so can't set all uppercase at once.
|
|
#11
|
||||
|
||||
|
Well, if the document contains mixed cases and you only want to change those ranges, you could use a Find/Replace macro, but such a macro could be simpler and faster than yours:
Code:
Sub Demo()
Application.ScreenUpdating = False
With ActiveDocument.Range
With .Find
.ClearFormatting
.Text = ""
.Font.AllCaps = True
.Forward = True
.MatchWildcards = False
.Wrap = wdFindStop
.Execute
End With
Do While .Find.Found = True
.Case = wdUpperCase
.Find.Execute
Loop
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#12
|
|||
|
|||
|
Hi guys,
I posted a question similar to this in another thread but would need to go further on this function. I have a document which have certain parts of text in ALL CAPS and some others in SMALL CAPS. So I am looking for a macro that changes such instances of text in "ALL CAPS" to uppercase. And any piece of text in "SMALL CAPS" to lowercase. Can this be done with a macro in one go? Many thanks! |
|
#13
|
|||
|
|||
|
You asked something like this in my post above that you can use as a response with only minor adaptations.
|
|
#14
|
|||
|
|||
|
Thatīs correct. However, I tried to tweak the code provided in the other post but did not work when I added the case change SMALL CAPS to lowercase:
With ActiveDocument.Range With .Find .Text = "*" .Font.ALLCAPS = True .Replacement.Font.ALLCAPS = False .Replacement.Text = "^&" .Forward = True .Wrap = wdFindStop .MatchWildcards = True .Format = True .Execute End With Do While .Find.Found .Case = wdUpperCase .Collapse wdCollapseEnd .Find.Execute Loop End With With ActiveDocument.Range With .Find .Text = "*" .Font.SmallCaps = True .Replacement.Font.SmallCaps = False .Replacement.Text = "^&" .Forward = True .Wrap = wdFindStop .MatchWildcards = True .Format = True .Execute End With Do While .Find.Found .Case = wdLowerCase .Collapse wdCollapseEnd .Find.Execute Loop End With End Sub |
|
#15
|
||||
|
||||
|
Try:
Code:
Sub Demo()
Application.ScreenUpdating = False
With ActiveDocument.Range
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Forward = True
.MatchWildcards = False
.Text = ""
.Font.SmallCaps = True
.Replacement.Font.SmallCaps = False
.Wrap = wdFindContinue
.Execute Replace:=wdReplaceAll
.Font.AllCaps = True
.Wrap = wdFindStop
.Execute
End With
Do While .Find.Found = True
.Case = wdUpperCase
.Find.Execute
Loop
End With
Application.ScreenUpdating = True
End Sub
PPS: When posting about related topics, please keep the posts in the same thread. Threads merged.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Need a Macro to Change Every Instance of Small Caps to All Caps and Reduce the Font by 2 Points
|
CrossReach | Word VBA | 2 | 11-13-2017 09:21 AM |
| How to find CAPITALIZED names and change them into small caps | dylan.ve | Word VBA | 5 | 02-25-2016 03:15 PM |
Change lower case to caps whole document
|
lmb100 | Word | 4 | 08-07-2015 06:57 AM |
| Using conditional formatining to change to all caps | Shades | Excel | 3 | 05-05-2014 06:05 AM |
| find&replace word in uppercase with word in lowercase | andrei | Word | 3 | 10-03-2011 05:11 AM |