Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 03-28-2024, 10:47 AM
vivka vivka is offline Capitalization macro doesn't work for hyphenated words or words after paretheses Windows 7 64bit Capitalization macro doesn't work for hyphenated words or words after paretheses Office 2016
Expert
 
Join Date: Jul 2023
Posts: 305
vivka is on a distinguished road
Default

Hi! Since "-" is a word, try the following basic code (without the exclusion check):
Code:
Sub Test()
Dim para As Paragraph
Dim oWd As range
    Application.ScreenUpdating = False
     For Each para In ActiveDocument.range.Paragraphs
      If para.Style = "Heading 1" _
      Or para.Style = "Heading 2" _
      Or para.Style = "Heading 3" _
      Or para.Style = "Report Title" _
      Or para.Style = "Report Subtitle" _
      Or para.Style = "Figure/Table Title" Then
         For Each oWd In para.range.words
            oWd.Select
            If oWd = "-" Or oWd = "(" Then
                selection.Characters.Last.Next = UCase(selection.Characters.Last.Next)
            End If
         Next oWd
      End If
     Next para
Application.ScreenUpdating = True
End Sub
Reply With Quote
 

Tags
capitalization, hyphenation



Similar Threads
Thread Thread Starter Forum Replies Last Post
Replace any UK Words to US words in the entire document laith93 Word VBA 4 12-25-2023 01:56 AM
Capitalization macro doesn't work for hyphenated words or words after paretheses Macro to insert certain words if the number of words than 20 laith93 Word VBA 6 10-28-2022 01:12 AM
How to find (highlight) two and more words in a list of 75k single words in Word 2010 Usora Word 8 05-29-2018 03:34 AM
Capitalization macro doesn't work for hyphenated words or words after paretheses How to mark underlined words in a sentence as A, B, C, D (beneath the words) thudangky Word 13 12-12-2013 02:22 AM
Why Words doesn’t show the style of the selected words automatically???? Jamal NUMAN Word 0 04-14-2011 03:20 PM

Other Forums: Access Forums

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