Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-29-2018, 03:21 AM
dita dita is offline Word macro to change ALL CAPS to UPPERCASE Windows XP Word macro to change ALL CAPS to UPPERCASE Office 2010 64bit
Advanced Beginner
Word macro to change ALL CAPS to UPPERCASE
 
Join Date: Apr 2018
Posts: 34
dita is on a distinguished road
Default Word macro to change ALL CAPS to UPPERCASE

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!
Reply With Quote
  #2  
Old 04-29-2018, 07:25 AM
eduzs eduzs is offline Word macro to change ALL CAPS to UPPERCASE Windows 10 Word macro to change ALL CAPS to UPPERCASE Office 2010 32bit
Expert
 
Join Date: May 2017
Posts: 262
eduzs is on a distinguished road
Default

Try this:

Backup the original file and code before doing any modification, test before use, use at your own.

Quote:
Sub Macro3()
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
End Sub
__________________
Backup your original file before doing any modification.
Reply With Quote
  #3  
Old 04-29-2018, 09:25 AM
dita dita is offline Word macro to change ALL CAPS to UPPERCASE Windows XP Word macro to change ALL CAPS to UPPERCASE Office 2010 64bit
Advanced Beginner
Word macro to change ALL CAPS to UPPERCASE
 
Join Date: Apr 2018
Posts: 34
dita is on a distinguished road
Default

It works!

I will try to tweak your code to make another find/replace.

Thanks so much!
Reply With Quote
  #4  
Old 04-29-2018, 09:18 PM
macropod's Avatar
macropod macropod is offline Word macro to change ALL CAPS to UPPERCASE Windows 7 64bit Word macro to change ALL CAPS to UPPERCASE Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #5  
Old 04-30-2018, 02:44 AM
eduzs eduzs is offline Word macro to change ALL CAPS to UPPERCASE Windows 10 Word macro to change ALL CAPS to UPPERCASE Office 2010 32bit
Expert
 
Join Date: May 2017
Posts: 262
eduzs is on a distinguished road
Default

Hi Macropod,

In the code above ".Collapse wdCollapseEnd" is really necessary? What it does?

Thanks
__________________
Backup your original file before doing any modification.
Reply With Quote
  #6  
Old 04-30-2018, 04:34 AM
Guessed's Avatar
Guessed Guessed is offline Word macro to change ALL CAPS to UPPERCASE Windows 10 Word macro to change ALL CAPS to UPPERCASE Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,977
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

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
Reply With Quote
  #7  
Old 04-30-2018, 04:35 AM
eduzs eduzs is offline Word macro to change ALL CAPS to UPPERCASE Windows 10 Word macro to change ALL CAPS to UPPERCASE Office 2010 32bit
Expert
 
Join Date: May 2017
Posts: 262
eduzs is on a distinguished road
Default

Superb! Thank you! I was planning to remove this line, not anymore!
__________________
Backup your original file before doing any modification.
Reply With Quote
  #8  
Old 04-30-2018, 06:12 AM
dita dita is offline Word macro to change ALL CAPS to UPPERCASE Windows XP Word macro to change ALL CAPS to UPPERCASE Office 2010 64bit
Advanced Beginner
Word macro to change ALL CAPS to UPPERCASE
 
Join Date: Apr 2018
Posts: 34
dita is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
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...
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.
Reply With Quote
  #9  
Old 04-30-2018, 02:34 PM
macropod's Avatar
macropod macropod is offline Word macro to change ALL CAPS to UPPERCASE Windows 7 64bit Word macro to change ALL CAPS to UPPERCASE Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by dita View Post
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.
You're missing the point - you don't need a macro at all (just select the whole document and use the 'Change Case' dropdown's 'UPPERCASE' option) or, if you're wedded to using a macro, anything to do with Find/Replace, hence:
Code:
Sub Demo(): ActiveDocument.Range.Case = wdUpperCase: End Sub
There it is, all in one line and way faster than eduzs' code.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #10  
Old 04-30-2018, 04:13 PM
eduzs eduzs is offline Word macro to change ALL CAPS to UPPERCASE Windows 10 Word macro to change ALL CAPS to UPPERCASE Office 2010 32bit
Expert
 
Join Date: May 2017
Posts: 262
eduzs is on a distinguished road
Default

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.
__________________
Backup your original file before doing any modification.
Reply With Quote
  #11  
Old 04-30-2018, 05:24 PM
macropod's Avatar
macropod macropod is offline Word macro to change ALL CAPS to UPPERCASE Windows 7 64bit Word macro to change ALL CAPS to UPPERCASE Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #12  
Old 05-20-2018, 01:02 AM
dita dita is offline Word macro to change ALL CAPS to UPPERCASE Windows XP Word macro to change ALL CAPS to UPPERCASE Office 2010 64bit
Advanced Beginner
Word macro to change ALL CAPS to UPPERCASE
 
Join Date: Apr 2018
Posts: 34
dita is on a distinguished road
Default Change case of text

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!
Reply With Quote
  #13  
Old 05-20-2018, 04:00 AM
eduzs eduzs is offline Word macro to change ALL CAPS to UPPERCASE Windows 10 Word macro to change ALL CAPS to UPPERCASE Office 2010 32bit
Expert
 
Join Date: May 2017
Posts: 262
eduzs is on a distinguished road
Default

You asked something like this in my post above that you can use as a response with only minor adaptations.
__________________
Backup your original file before doing any modification.
Reply With Quote
  #14  
Old 05-20-2018, 10:55 AM
dita dita is offline Word macro to change ALL CAPS to UPPERCASE Windows XP Word macro to change ALL CAPS to UPPERCASE Office 2010 64bit
Advanced Beginner
Word macro to change ALL CAPS to UPPERCASE
 
Join Date: Apr 2018
Posts: 34
dita is on a distinguished road
Default

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
Reply With Quote
  #15  
Old 05-20-2018, 10:56 PM
macropod's Avatar
macropod macropod is offline Word macro to change ALL CAPS to UPPERCASE Windows 7 64bit Word macro to change ALL CAPS to UPPERCASE Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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
PS: When posting code, please use the code tags, indicated by the # button on the posting menu. Without them, your code loses much of whatever structure it had.

PPS: When posting about related topics, please keep the posts in the same thread. Threads merged.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Word macro to change ALL CAPS to UPPERCASE 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
Word macro to change ALL CAPS to UPPERCASE 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

Other Forums: Access Forums

All times are GMT -7. The time now is 05:42 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft