I am replacing all CamelCase characters in my documents with Courier New font, etc. But, I find that it doesn't find words like 'camelCase' (which starts with lowercase letter) but find everything beginning with uppercase, e.g. CamelCase.
Any ideas?
Code: Select all
Sub SetCamelCase()
' Handle simple form of CamelCase
Application.ScreenUpdating = False
Selection.HomeKey Unit:=wdStory
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "[A-Z][a-z]@[A-Z][a-z]@"
.Replacement.Text = "^&"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
While (Selection.Find.Execute)
Selection.Start = SetToCourierNew
Wend
Application.ScreenUpdating = True
End Sub
Private Function SetToCourierNew() As Long
Dim strDelim As String
On Error GoTo ExitHandler
' Delimiters
strDelim = " " & vbCr & vbTab & vbLf & Chr(11)
With Selection
' Select whole word
.MoveStartUntil strDelim, wdBackward
.MoveEndUntil strDelim, wdForward
' Set font
.Font.Name = "Courier New"
' Make sure this is not checked for spelling
.NoProofing = True
End With
SetToCourierNew = Selection.End + 1
ExitHandler:
End Function
Robie.