Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #6  
Old 09-05-2019, 03:08 PM
jeffreybrown jeffreybrown is offline VBA to convert a line of text to title case Windows 10 VBA to convert a line of text to title case Office 2016
Expert
VBA to convert a line of text to title case
 
Join Date: Apr 2016
Posts: 673
jeffreybrown has a spectacular aura aboutjeffreybrown has a spectacular aura about
Default

Hi Paul,

Okay I've found something to start with, but can't figure out how to more one past the em dash.

Again, I'm going to start with something simple and then try to move on to the bigger task. This code below will allow me to bold the first part of this paragraph all that which is before the em dash.

I have one line in my document for starters.

ADPE—AUTOMATED DATA PROCESSING EQUIPMENT

Running the macro below the .start is 5 and then the .end equals 4 so the paragraph collapses to the first 4 characters and bolds.

Not sure how to get the start to be 6 and then proceed to the end and collapse?

Code:
Sub Bold_Terms2()
    With Selection.Range
      With .Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Text = "^+"
        .Replacement.Text = ""
        .Forward = True
        .Format = False
        .MatchWildcards = False
        .Wrap = wdFindStop
        .Execute
      End With
      Do While .Find.Found
      If .Find.Found = True Then
        With .Duplicate
          .Start = .Paragraphs.First.Range.Start
          .End = .End - 1
          .Font.Bold = True
        End With
        .Collapse wdCollapseEnd
        .Find.Execute
      End If
        Loop
    End With
End Sub
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA to convert a line of text to title case How do I convert a line of text to title case? neilfxb Word 21 02-22-2023 12:47 PM
Macro that formats (true title) case by Heading style Marrick13 Word VBA 11 09-20-2015 06:29 PM
VBA to convert a line of text to title case Customising a style that uses Title Case formatting Madanjeet Word 6 05-18-2015 10:11 AM
Stop review query when small case at beginning of line dsrose Word 2 01-22-2014 12:19 AM
VBA to convert a line of text to title case True Title Case for First Row of All Tables Marrick13 Word VBA 14 12-11-2013 09:12 PM

Other Forums: Access Forums

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