Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #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
  #2  
Old 05-12-2020, 04:58 PM
macropod's Avatar
macropod macropod is offline Converting casing in MS word Windows 7 64bit Converting casing in MS word Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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

See: https://www.msofficeforums.com/78192-post3.html
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 05-22-2020, 05:30 AM
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

Quote:
Originally Posted by macropod View Post
Tried incorporating the array part on the code above but it is not working.
Reply With Quote
  #4  
Old 05-22-2020, 06:02 AM
macropod's Avatar
macropod macropod is offline Converting casing in MS word Windows 7 64bit Converting casing in MS word Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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

Maybe you should read the whole thread more closely - it gives a complete solution.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Tags
case, ms word 2013, vba

Thread Tools
Display Modes


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 12: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