View Single Post
 
Old 03-09-2023, 03:35 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

It is pretty much the same way. At its simplest you could follow this pattern
Code:
Sub GetStyled()
  Dim sSty As String
  sSty = Selection.Style
  If sSty = "Normal" Then
    Selection.Style = "Heading 2"
  Else
    Selection.Style = "Heading 3"
  End If
End Sub
If your selection includes multiple styles (eg more than one paragraph selected or character style + paragraph style) then you may need to complicate the code to get the right results.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote