Results 1 to 5 of 5

Thread: How to check if a Word Style exists

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    My code for this is:

    Sub test_style_exists()
        Dim test_style As String    
        test_style = "Quota"
        MsgBox "Style " & test_style & " exists in " & ActiveDocument.Name & "?" & vbCr & _
        style_exists(ActiveDocument, test_style)        
    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
    Any comments on using set MyStyle versus testing NameLocal?

    Richard.
    Last edited by Aussiebear; 02-27-2025 at 01:33 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •