Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-24-2016, 05:09 AM
dylan.ve dylan.ve is offline How to find CAPITALIZED names and change them into small caps Mac OS X How to find CAPITALIZED names and change them into small caps Office for Mac 2011
Novice
How to find CAPITALIZED names and change them into small caps
 
Join Date: Feb 2016
Posts: 3
dylan.ve is on a distinguished road
Exclamation How to find CAPITALIZED names and change them into small caps

Dear all,



I'm correcting a manuscript of 7650 pages in Word before I import it in InDesign.
References to persons are consistenlty written down like this:

FERNANDEZ Ferdinand
DE SMEDT Floris
LA CROIX-FLAGEY Marcelle
COMTESSE DE FLANDRE Marie

I need to find a way to script a comma (,) after 1, 2 or 3 capitalized parts of names. Next to that, I want to have the (hard) ALL CAPS to appear in SMALL CAPS

FERNANDEZ, Ferdinand
DE SMEDT, Floris
LA CROIX-FLAGEY, Marcelle
COMTESSE DE FLANDRE, Marie

Is this something that can be done in Word?

Thanks in advance,

All the best,
Dylan
Reply With Quote
  #2  
Old 02-24-2016, 02:23 PM
macropod's Avatar
macropod macropod is offline How to find CAPITALIZED names and change them into small caps Windows 7 64bit How to find CAPITALIZED names and change them into small caps 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

You could do that with a macro like:
Code:
Sub Demo()
Application.ScreenUpdating = False
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "<[A-Z]{2,3} [A-Z]{2,}>"
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindStop
    .Format = False
    .MatchWildcards = True
    .Execute
  End With
  Do While .Find.Found
    .Case = wdTitleWord
    .Font.SmallCaps = True
    .Collapse wdCollapseEnd
    .Find.Execute
  Loop
End With
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "<[A-Z\-]{4,}>"
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindStop
    .Format = False
    .MatchWildcards = True
    .Execute
  End With
  Do While .Find.Found
    .Case = wdTitleWord
    .Font.SmallCaps = True
    .Collapse wdCollapseEnd
    .Find.Execute
  Loop
End With
Application.ScreenUpdating = True
End Sub
However, there is no way of differentiating between acronyms (e.g. BBC) and names, so you'll need to check that your acronyms (and any other words to need to retain capitalized) are intact after running the macro.

For PC macro installation & usage instructions, see: http://www.gmayor.com/installing_macro.htm
For Mac macro installation & usage instructions, see: http://word.mvps.org/Mac/InstallMacro.html
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 02-25-2016, 03:51 AM
dylan.ve dylan.ve is offline How to find CAPITALIZED names and change them into small caps Mac OS X How to find CAPITALIZED names and change them into small caps Office for Mac 2011
Novice
How to find CAPITALIZED names and change them into small caps
 
Join Date: Feb 2016
Posts: 3
dylan.ve is on a distinguished road
Default

Dear Paul Edstein,

The macro runs a mistake in my case unfortunately. (Error 5825)
I'm not familiar with VBA and writing scripts.

Thanks in advance.

Cheers,
Dylan
Attached Images
File Type: png Schermafbeelding 2016-02-25 om 11.49.24.png (169.8 KB, 16 views)
Reply With Quote
  #4  
Old 02-25-2016, 04:56 AM
macropod's Avatar
macropod macropod is offline How to find CAPITALIZED names and change them into small caps Windows 7 64bit How to find CAPITALIZED names and change them into small caps 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

The error you're seeing with the code is most likely due to your system using non-English regional settings. You should be able to resolve that by changing:
"<[A-Z]{2,3} [A-Z]{2,}>"
to:
"<[A-Z]{2;3} [A-Z]{2;}>"
and changing:
"<[A-Z\-]{4,}>"
to:
"<[A-Z\-]{4;}>"
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 02-25-2016, 06:31 AM
dylan.ve dylan.ve is offline How to find CAPITALIZED names and change them into small caps Mac OS X How to find CAPITALIZED names and change them into small caps Office for Mac 2011
Novice
How to find CAPITALIZED names and change them into small caps
 
Join Date: Feb 2016
Posts: 3
dylan.ve is on a distinguished road
Default

It does work now! Thank you very much.

At first sight it didn't change the acronyms, which is good.

Is there a way to modify this script for the acronyms in the body text so they will appear also in SMALL CAPS like this and not like this SMALL CAPS

Thanks in advance.

All the best,
Dylan
Reply With Quote
  #6  
Old 02-25-2016, 03:15 PM
macropod's Avatar
macropod macropod is offline How to find CAPITALIZED names and change them into small caps Windows 7 64bit How to find CAPITALIZED names and change them into small caps 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

As the code doesn't affect 2-letter or 3-letter acronyms, you shouldn't be getting any appearing as SMALL CAPS - unless they're already formatted that way.

Assuming they're just ordinary caps, the following code should work:
Code:
Sub Demo()
Application.ScreenUpdating = False
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "<[A-Z]{2;3}>"
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindStop
    .Format = False
    .MatchWildcards = True
    .Execute
  End With
  Do While .Find.Found
    .Text = LCase(.Text)
    .Font.SmallCaps = True
    .Collapse wdCollapseEnd
    .Find.Execute
  Loop
End With
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "<[a-z]{2;3} "
    .Font.SmallCaps = True
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindStop
    .Format = False
    .MatchWildcards = True
    .Execute
  End With
  Do While .Find.Found
    If UCase(.Words.Last.Next) = .Words.Last.Next Then
      .Text = UCase(.Text)
      .Font.SmallCaps = False
    End If
    .Collapse wdCollapseEnd
    .Find.Execute
  Loop
End With
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "<[A-Z]{2;3} [A-Z]{2;}>"
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindStop
    .Format = False
    .MatchWildcards = True
    .Execute
  End With
  Do While .Find.Found
    .Case = wdTitleWord
    .Font.SmallCaps = True
    .Collapse wdCollapseEnd
    .Find.Execute
  Loop
End With
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "<[A-Z\-]{4;}>"
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindStop
    .Format = False
    .MatchWildcards = True
    .Execute
  End With
  Do While .Find.Found
    .Case = wdTitleWord
    .Font.SmallCaps = True
    .Collapse wdCollapseEnd
    .Find.Execute
  Loop
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]

Last edited by macropod; 02-25-2016 at 03:31 PM. Reason: Code Revision
Reply With Quote
Reply

Tags
allcaps, smallcaps, wildcards



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to find CAPITALIZED names and change them into small caps Include small caps in hierarchical multi-level list Hardbottle Word 1 06-20-2015 05:12 AM
change non capitalized text to capitalized text antoniob Excel 8 10-13-2014 09:11 AM
Is there a way to find CAPITALIZED words in a doc? Bobosmite Word 8 01-28-2014 03:53 PM
How to find CAPITALIZED names and change them into small caps small caps auto check gene Word 1 12-03-2011 03:04 PM
French accents in small caps nuitsdete Word 0 09-23-2011 01:53 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:57 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