|
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 boolStyleExists(strStylename As String) As Boolean
' Procedure : boolStyleExists
' Description: Determine if a style is/has been defined in the document.
' Copyright: Chris Greaves Inc.
' Inputs: String (style name)
' Returns: FALSE if we need to define the style before using it.
' Assumes: None.
' Side Effects: None.
' Tested: By the calls shown below.
'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?
boolStyleExists = False
On Error Resume Next
boolStyleExists = ActiveDocument.Styles(strStylename).InUse
'Sub TESTboolStyleExists()
'MsgBox boolStyleExists("Normal") ' TRUE; a paragraph style
'MsgBox boolStyleExists("Default Paragraph Font") ' TRUE; a character style
'MsgBox boolStyleExists("This can't possibly exist, can it?") ' False
'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 |