#1
|
|||
|
|||
Macro to capitalize first letter after timecode + tab
Hello all,
I am looking to write a macro where when I run it, it will capitalize the first letter of any line that has a timecode and then is indented (via TAB). The format of the timecode is this: 0:53:04.9 so I wish the “s” in that first word of this line will get capitalized when I run the new macro I'm trying to create. (Where the gap between the 9 and the s is a tab-created gap in Word) I found a way to capitalize the first letter after a colon using the macro I found on this site: https://cybertext.wordpress.com/2011...to-upper-case/ While searching for a macro that does that I came across several searches that ended on this forum, so I was hoping I could find some help here. I am unfamiliar with VBA at the moment so writing it myself seems challenging. Just looking at the other macro, I'm guessing I need to change the .Text part of the macro to numbers 0-9, and somewhere in the macro I need to specify the tab. Or maybe it should be written from scratch. Thanks for any help. |
#2
|
||||
|
||||
The following macro should do the job
Code:
Sub FormatTimeCode() Dim oRng As Range Set oRng = ActiveDocument.Range With oRng.Find Do While .Execute(FindText:="[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}.[0-9]{1,2} [a-z]", MatchWildcards:=True) oRng.Characters.Last.Case = wdUpperCase oRng.Characters.Last.InsertBefore vbTab oRng.Collapse 0 Loop End With lbl_Exit: Set oRng = Nothing Exit Sub End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Only Capitalize First Letter & Delete Last Name | zulhfreelancer | Excel | 5 | 12-10-2012 07:51 AM |
Exceptions for 'Capitalize first letter of sentences' | gazpacho | Word | 1 | 01-12-2012 11:43 AM |
Macro to get first letter of a page in the header | faramir | Word VBA | 4 | 11-16-2011 05:43 AM |
is it possibe to capitalize every letter after a "colon space" | angeltread | Word VBA | 4 | 01-17-2011 03:50 PM |
capitalize first letter of sentences | norco1 | Word | 0 | 06-25-2006 12:37 PM |