View Single Post
 
Old 11-29-2023, 03:37 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

This might be easier
Code:
Sub ChrSixBis()
  With ActiveDocument.Paragraphs(5).Range
    If LCase(.Text) Like "title.*" Then
      .Style = "Heading 1"
      .Words(1).Case = wdLowerCase
      .Words(1).Font.SmallCaps = True
    Else
      MsgBox "Not Found"
    End If
  End With
End Sub
I would recommend you add an error checker in case the document doesn't have 5 paragraphs. Also, if you are trying to assign a custom style, you might also need an error checker to ensure that style exists in the document.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote