Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-06-2023, 12:14 PM
carrollmt carrollmt is offline Macro to change Small Caps to Lower Case Windows 10 Macro to change Small Caps to Lower Case Office 2016
Novice
Macro to change Small Caps to Lower Case
 
Join Date: Mar 2023
Posts: 4
carrollmt is on a distinguished road
Default Macro to change Small Caps to Lower Case

Hello, i've tried looking online & couldn't find anything in this Forum, but I am trying to create a Macro in Word that will find all instances of small caps & change them to lower case.

I am running Windows 10 & MS Word 2016.



Any help would be greatly appreciated!
Reply With Quote
  #2  
Old 03-06-2023, 09:27 PM
gmayor's Avatar
gmayor gmayor is offline Macro to change Small Caps to Lower Case Windows 10 Macro to change Small Caps to Lower Case Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,137
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

How about
Code:
Sub Macro1()
    Selection.Find.ClearFormatting
    With Selection.Find.Font
        .SmallCaps = True
        .AllCaps = False
    End With
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = ""
        .Replacement.Text = ""
        .Replacement.Font.SmallCaps = False
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 03-06-2023, 09:27 PM
BrianHoard BrianHoard is offline Macro to change Small Caps to Lower Case Windows 10 Macro to change Small Caps to Lower Case Office 2019
Advanced Beginner
 
Join Date: Jul 2022
Location: Haymarket, VA USA
Posts: 85
BrianHoard is on a distinguished road
Default

I'm using Office 2019, but please see if this works for you. I recorded a Macro to do as you mentioned, then modified that code to get this. I added an Undo record so the entire script can be undone in one go, and used the document range instead of selection.
I now see that Graham posted an answer already. I'm still learning this, so you're likely better off going with his solution.


Code:
Sub smallCaps2Lowercase()
  Dim bhhUndo As UndoRecord
  Dim scriptName As String
  Dim rng_doc As Range
    
  scriptName = "smallCaps2Lowercase"
  Set rng_doc = ActiveDocument.Range
  Application.ScreenUpdating = False
  
  ' Begin undo record
  Set bhhUndo = Application.UndoRecord
  bhhUndo.StartCustomRecord (scriptName)
  
    ' Find/replace all text from smallCaps to lowercase.
  rng_doc.Find.ClearFormatting
  
  With rng_doc.Find.Font
    .SmallCaps = True
    .AllCaps = False
  End With
  
  rng_doc.Find.Replacement.ClearFormatting
  With rng_doc.Find.Replacement.Font
    .SmallCaps = False
    .AllCaps = False
  End With
  
  With rng_doc.Find
    .Text = "*"
    .Replacement.Text = LCase("")
    .Forward = True
    .Wrap = wdFindContinue
    .Format = True
    .MatchCase = False
    .MatchWholeWord = False
    .MatchAllWordForms = False
    .MatchSoundsLike = False
    .MatchWildcards = True
  End With
  
  rng_doc.Find.Execute Replace:=wdReplaceAll

  Application.ScreenUpdating = True
  bhhUndo.EndCustomRecord ' End undo

End Sub
Reply With Quote
  #4  
Old 03-07-2023, 06:21 AM
carrollmt carrollmt is offline Macro to change Small Caps to Lower Case Windows 10 Macro to change Small Caps to Lower Case Office 2016
Novice
Macro to change Small Caps to Lower Case
 
Join Date: Mar 2023
Posts: 4
carrollmt is on a distinguished road
Default

Unfortunately, this didn't seem to do anything. It runs without any errors, but the SmallCaps doesn't change. Most of the instances appear in footnotes, does that make a difference?

Quote:
Originally Posted by gmayor View Post
How about
Code:
Sub Macro1()
    Selection.Find.ClearFormatting
    With Selection.Find.Font
        .SmallCaps = True
        .AllCaps = False
    End With
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = ""
        .Replacement.Text = ""
        .Replacement.Font.SmallCaps = False
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
End Sub
Reply With Quote
  #5  
Old 03-07-2023, 06:26 AM
carrollmt carrollmt is offline Macro to change Small Caps to Lower Case Windows 10 Macro to change Small Caps to Lower Case Office 2016
Novice
Macro to change Small Caps to Lower Case
 
Join Date: Mar 2023
Posts: 4
carrollmt is on a distinguished road
Default

Hmm. When I run this, it ends up crashing Word. I think you might be onto something though. I might try recording it myself & see if that works.

Quote:
Originally Posted by BrianHoard View Post
I'm using Office 2019, but please see if this works for you. I recorded a Macro to do as you mentioned, then modified that code to get this. I added an Undo record so the entire script can be undone in one go, and used the document range instead of selection.
I now see that Graham posted an answer already. I'm still learning this, so you're likely better off going with his solution.


Code:
Sub smallCaps2Lowercase()
  Dim bhhUndo As UndoRecord
  Dim scriptName As String
  Dim rng_doc As Range
    
  scriptName = "smallCaps2Lowercase"
  Set rng_doc = ActiveDocument.Range
  Application.ScreenUpdating = False
  
  ' Begin undo record
  Set bhhUndo = Application.UndoRecord
  bhhUndo.StartCustomRecord (scriptName)
  
    ' Find/replace all text from smallCaps to lowercase.
  rng_doc.Find.ClearFormatting
  
  With rng_doc.Find.Font
    .SmallCaps = True
    .AllCaps = False
  End With
  
  rng_doc.Find.Replacement.ClearFormatting
  With rng_doc.Find.Replacement.Font
    .SmallCaps = False
    .AllCaps = False
  End With
  
  With rng_doc.Find
    .Text = "*"
    .Replacement.Text = LCase("")
    .Forward = True
    .Wrap = wdFindContinue
    .Format = True
    .MatchCase = False
    .MatchWholeWord = False
    .MatchAllWordForms = False
    .MatchSoundsLike = False
    .MatchWildcards = True
  End With
  
  rng_doc.Find.Execute Replace:=wdReplaceAll

  Application.ScreenUpdating = True
  bhhUndo.EndCustomRecord ' End undo

End Sub
Reply With Quote
  #6  
Old 03-07-2023, 09:19 AM
carrollmt carrollmt is offline Macro to change Small Caps to Lower Case Windows 10 Macro to change Small Caps to Lower Case Office 2016
Novice
Macro to change Small Caps to Lower Case
 
Join Date: Mar 2023
Posts: 4
carrollmt is on a distinguished road
Default

Looks like I was able to get it to work. I wasn't having any luck with the Macro changing SmallCaps that are in the footnotes, but using the following code, it seems to work so far:

Sub Macro2()
Dim rngStory As Range
For Each rngStory In ActiveDocument.StoryRanges
With rngStory.Find
.Font.SmallCaps = True
.Replacement.Font.SmallCaps = False
.Wrap = wdFindContinue
.Execute Replace:=wdReplaceAll
End With
Next rngStory
End Sub
Reply With Quote
Reply

Tags
macro, small caps



Similar Threads
Thread Thread Starter Forum Replies Last Post
Powerpoint-2019 Text in selected theme remains in All Caps even when small caps option is selected Tanasha4 PowerPoint 2 04-06-2019 07:53 PM
Macro to change Small Caps to Lower Case Toggle between upper case, lower case, etc... by one single macro on a Mac, to emulate Shift + F3 on gloub Word VBA 2 01-30-2019 12:40 PM
Macro to change Small Caps to Lower Case 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
Macro to change Small Caps to Lower Case Change lower case to caps whole document lmb100 Word 4 08-07-2015 06:57 AM

Other Forums: Access Forums

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


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