Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-24-2017, 10:18 AM
iwonder iwonder is offline Capitalized words to smallcaps on user approval Windows 10 Capitalized words to smallcaps on user approval Office 2013
Novice
Capitalized words to smallcaps on user approval
 
Join Date: Jun 2017
Location: France
Posts: 10
iwonder is on a distinguished road
Default Capitalized words to smallcaps on user approval

Hi !

I'm using the following code (adapted from Macropod's code [thanks to him !]) to do the job on all concerned words (2 characters or more) of the document, and it works fine.

But now I'd like the user to be asked if he wants the replacement with SmallCaps or not (if not, nothing will be changed) on each capitalized word found.
Could someone help me ?
Hope my English is clear enough...



Code:
Sub ALLCAPS_TO_SMALLCAPS()
'
Application.ScreenUpdating = False
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "<[A-Z][A-Z]*>"
    .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
I'm not a coder at all, just trying to adapt codes that I find, to my own needs.
Reply With Quote
  #2  
Old 06-24-2017, 11:19 AM
gmaxey gmaxey is offline Capitalized words to smallcaps on user approval Windows 7 32bit Capitalized words to smallcaps on user approval Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Code:
Sub ALLCAPS_TO_SMALLCAPS()
Application.ScreenUpdating = False
Dim oRng As Range
  Set oRng = ActiveDocument.Range
  With oRng.Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "<[A-Z][A-Z]*>"
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindStop
    .Format = False
    .MatchWildcards = True
    While .Execute
      oRng.Select
      If MsgBox("Reformat?", vbQuestion + vbYesNo) = vbYes Then
        oRng.Case = wdTitleWord
        oRng.Font.SmallCaps = True
      End If
      oRng.Collapse wdCollapseEnd
    Wend
  End With
Application.ScreenUpdating = True
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #3  
Old 06-24-2017, 11:53 AM
iwonder iwonder is offline Capitalized words to smallcaps on user approval Windows 10 Capitalized words to smallcaps on user approval Office 2013
Novice
Capitalized words to smallcaps on user approval
 
Join Date: Jun 2017
Location: France
Posts: 10
iwonder is on a distinguished road
Default

Thanks Greg, but this asks for reformatting but dosen't show the selected word to reformat...
Something is missing i guess

Quote:
Originally Posted by gmaxey View Post
Code:
Sub ALLCAPS_TO_SMALLCAPS()
Application.ScreenUpdating = False
Dim oRng As Range
  Set oRng = ActiveDocument.Range
  With oRng.Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "<[A-Z][A-Z]*>"
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindStop
    .Format = False
    .MatchWildcards = True
    While .Execute
      oRng.Select
      If MsgBox("Reformat?", vbQuestion + vbYesNo) = vbYes Then
        oRng.Case = wdTitleWord
        oRng.Font.SmallCaps = True
      End If
      oRng.Collapse wdCollapseEnd
    Wend
  End With
Application.ScreenUpdating = True
End Sub
Reply With Quote
  #4  
Old 06-24-2017, 12:08 PM
gmaxey gmaxey is offline Capitalized words to smallcaps on user approval Windows 7 32bit Capitalized words to smallcaps on user approval Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Take out this line:
Application.ScreenUpdating = False
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #5  
Old 06-24-2017, 02:02 PM
iwonder iwonder is offline Capitalized words to smallcaps on user approval Windows 10 Capitalized words to smallcaps on user approval Office 2013
Novice
Capitalized words to smallcaps on user approval
 
Join Date: Jun 2017
Location: France
Posts: 10
iwonder is on a distinguished road
Default

Many thanks Greg ! That makes the difference !!!!
Thanks too for your word_tip_pages, they helped me a lot with word stuff !


Quote:
Originally Posted by gmaxey View Post
Take out this line:
Application.ScreenUpdating = False
Reply With Quote
Reply

Tags
allcaps smallcaps user



Similar Threads
Thread Thread Starter Forum Replies Last Post
Staged Approval - Fillable Form - Digital Signature Barters Word 0 06-03-2015 06:02 PM
Capitalized words to smallcaps on user approval How to keep a word with capitalized first letter, but not at the beginning of a sentence? xiangwulu Word 4 10-31-2014 09:00 AM
change non capitalized text to capitalized text antoniob Excel 8 10-13-2014 09:11 AM
Capitalized words to smallcaps on user approval weird smallcaps phenomenon franklekens Word 8 08-31-2014 12:35 AM
Is there a way to find CAPITALIZED words in a doc? Bobosmite Word 8 01-28-2014 03:53 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:09 PM.


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