|
Visual Basic (VB and VBA) |
|
Copyright 1999-2001 Christopher Greaves. All rights reserved. Home Page and email to [email protected] |
| If in doubt, record a macro and inspect the entrails! |
Please read the DISCLAIMER.
Here is an INDEX to all the procedures.
You will probably need one copy of my GLOBAL DECLARATIONS.
Public Function boolStyleIsValid(strStylename As String) As Boolean
'If I am reading your code correctly, it checks styles that already exist in a document to see which ones are built-in styles. My problem is that I am trying to verify if a proposed new style name is reserved exclusively for a Word built-in style that has not yet been used in the active document. Unfortunately, because the style cannot be created unless the style name is valid, I can't check the style's built-in property. However, I can't create the style if the name is invalid because it reserved for use by a Word built-in style. Is there a way around this conundrum?
boolStyleIsValid = True ' default result is success
On Error GoTo Failed
ActiveDocument.Styles.Add Name:=strStylename, Type:=wdStyleTypeParagraph
On Error GoTo 0
GoTo Success
Failed:
boolStyleIsValid = False
Success:
'Sub TESTboolStyleIsValid()
'MsgBox boolStyleIsValid("Heading 1")
'MsgBox boolStyleIsValid("Heading 9")
'MsgBox boolStyleIsValid("Heading hooray")
'End Sub
End Function
| We all knew nothing when we started … |
|
Home Page and Contact Information Send email to [email protected]. This page was last updated Thursday, November 15, 2001 |