B
Bill Bowen
We have been working with a vendor on an issue where a numbering tool
utility of theirs essentially takes a document and analyzes all of the
styles to determine if they are part of an outline numbering scheme.
The problem is that whatever they are using to determine if the style
is part of a scheme iis changing the InUse property of each style in
the document to TRUE. This means that when users work in the document,
all styles in the document become "available styles" or InUse.
So I have a couple of questions. I've tried writing code that will
capture which styles were InUse before their utility is run. This
routine stores each style whose InUse status is set to True into an
array.
<<<<
Public Sub InUseStyles()
Dim n As Integer, x As Integer, y As Integer
Dim TemplateName As String
Dim StylesInUse() As Variant
Dim StyleName As Variant
Dim Styles As Styles
Set Styles = ActiveDocument.Styles
ReDim StylesInUse(0)
For n = 1 To Styles.Count
If Styles(n).InUse = True Then
ReDim Preserve StylesInUse(UBound(StylesInUse) + 1)
StylesInUse(UBound(StylesInUse)) = Styles(n).NameLocal
End If
Next n
End Sub
This procedure works very well in collecting those styles InUse.
But then I want to call their utility (which works fine) and then
reset only those styles that were InUse before I ran their utility.
Here is what I'm doing,
<<<<<
'Now we reset the InUse property back to it's original state
'This first part sets the InUse property of all styles back to false.
Perhaps extraneous...
For x = 1 To ActiveDocument.Styles.Count
ActiveDocument.Styles(x).InUse = False
Next
'This section restores the original InUse styles to True
For y = 1 To UBound(StylesInUse)
Styles(StylesInUse(y)).InUse = True
Next
But I keep getting a "Can't assign to read-only property" of the
section where I set each style to False. I assume it has to do with
not being able to delete Normal or Heading 1, etc... but I'm not sure.
Can anyone tell me if what I am trying to do can be done? I would
prefer if they would just tell us what they are doing to set each
style to InUse but they won't! I just don't think I understand the
InUse property as well as I could. But the vendor doesn't either!
Thanks,
Bill
utility of theirs essentially takes a document and analyzes all of the
styles to determine if they are part of an outline numbering scheme.
The problem is that whatever they are using to determine if the style
is part of a scheme iis changing the InUse property of each style in
the document to TRUE. This means that when users work in the document,
all styles in the document become "available styles" or InUse.
So I have a couple of questions. I've tried writing code that will
capture which styles were InUse before their utility is run. This
routine stores each style whose InUse status is set to True into an
array.
<<<<
Public Sub InUseStyles()
Dim n As Integer, x As Integer, y As Integer
Dim TemplateName As String
Dim StylesInUse() As Variant
Dim StyleName As Variant
Dim Styles As Styles
Set Styles = ActiveDocument.Styles
ReDim StylesInUse(0)
For n = 1 To Styles.Count
If Styles(n).InUse = True Then
ReDim Preserve StylesInUse(UBound(StylesInUse) + 1)
StylesInUse(UBound(StylesInUse)) = Styles(n).NameLocal
End If
Next n
End Sub
This procedure works very well in collecting those styles InUse.
But then I want to call their utility (which works fine) and then
reset only those styles that were InUse before I ran their utility.
Here is what I'm doing,
<<<<<
'Now we reset the InUse property back to it's original state
'This first part sets the InUse property of all styles back to false.
Perhaps extraneous...
For x = 1 To ActiveDocument.Styles.Count
ActiveDocument.Styles(x).InUse = False
Next
'This section restores the original InUse styles to True
For y = 1 To UBound(StylesInUse)
Styles(StylesInUse(y)).InUse = True
Next
But I keep getting a "Can't assign to read-only property" of the
section where I set each style to False. I assume it has to do with
not being able to delete Normal or Heading 1, etc... but I'm not sure.
Can anyone tell me if what I am trying to do can be done? I would
prefer if they would just tell us what they are doing to set each
style to InUse but they won't! I just don't think I understand the
InUse property as well as I could. But the vendor doesn't either!
Thanks,
Bill