![]() |
#1
|
|||
|
|||
![]()
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! |
#2
|
||||
|
||||
![]()
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 |
#3
|
|||
|
|||
![]()
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 |
#4
|
|||
|
|||
![]()
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:
|
#5
|
|||
|
|||
![]()
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:
|
#6
|
|||
|
|||
![]()
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 |
![]() |
Tags |
macro, small caps |
|
![]() |
||||
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 |
![]() |
gloub | Word VBA | 2 | 01-30-2019 12:40 PM |
![]() |
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 |
![]() |
lmb100 | Word | 4 | 08-07-2015 06:57 AM |