Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 05-12-2020, 04:10 PM
JPS0710 JPS0710 is offline Converting casing in MS word Windows 10 Converting casing in MS word Office 2013
Novice
Converting casing in MS word
 
Join Date: May 2020
Posts: 2
JPS0710 is on a distinguished road
Default Converting casing in MS word

The code below converts words in a specific style into title case, except for acronyms.

However, there are specific words that I would like to add for the exception and these words should stay in lower case format (and, for, but, etc.)

So far, this is what I came up with and currently not working:

Public Sub TitleCaseDocument()
Dim myDoc As Document: Set myDoc = ActiveDocument
Dim myPara As Word.Paragraph

For Each myPara In myDoc.StoryRanges.Item(wdMainTextStory).Paragraphs

If myPara.Style.NameLocal = "K Level 1" Then
TitleParagraph myPara
End If

Next
End Sub

Public Sub TitleParagraph(ByVal ipPara As Word.Paragraph)

Dim myText As Range
Dim Strtext As String
Strtext = "and,of"
For Each myText In ipPara.Range.Words

If Not UCase$(myText.Text) = myText.Text Then
myText.Words.Item(1).Case = wdTitleWord

Else If Not Strtext = myText.Text Then
myText.Words.Item(1).Case = wdTitleWord

End If
Next
End Sub
Reply With Quote
 

Tags
case, ms word 2013, vba



Similar Threads
Thread Thread Starter Forum Replies Last Post
Corrupted word documents after converting pdf files to word The Balf Word 3 04-24-2017 12:02 PM
Converting casing in MS word Converting a PDF to Word jeffreybrown Word 2 05-03-2016 03:06 PM
Converting casing in MS word Converting an orignal word file from xml, back to word Diane P Word 1 07-10-2015 08:27 PM
Converting casing in MS word converting word doc to e pub klemens swib Word 17 06-28-2013 02:59 PM
Converting casing in MS word Converting pdf... to Word ??? admin4ever Word 1 05-27-2011 02:58 PM

Other Forums: Access Forums

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


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