View Single Post
 
Old 08-02-2021, 09:45 PM
stky stky is offline Windows 10 Office 2013
Advanced Beginner
 
Join Date: Apr 2021
Posts: 30
stky is on a distinguished road
Default Need to do this for more than 20 styles is any option is there. help me on this

Sub test_style_exists()

Dim test_style As String
On Error Resume Next
test_style = "Quota"
MsgBox "Style " & test_style & " exists in " & ActiveDocument.Name & "?" & vbCr & _
style_exists(ActiveDocument, test_style)


If Not MyStyle Is Nothing Then
Set MyStyle = Application.ActiveDocument.Styles.Add(test_style, wdStyleTypeParagraph)
End If

End Sub

Function style_exists(test_document As Word.Document, style_name As String) As Boolean

style_exists = False
On Error Resume Next
style_exists = test_document.Styles(style_name).NameLocal = style_name

End Function
Reply With Quote