Is there an easy way in vba (word 2010) to detect the used styles in a document and add them as check boxes on a userform, where I can hide/show the styles by toggle check box status? And automatically add another check box, named "All visible" that shows/hide all? (Except from two pre-defined styles). And - if all the styles are present - the "All visible" check box turns on? And vice versa?
The reason I ask, is that I am a writer/producer - and when going into production I write notes that aren´t interesting for the whole crew.
I kind of achieved this through an endless, stupid and not bug-free code. (Sometimes I have to check the boxes all over again, even if I have pressed the "All visible"-checkbox)
I think there might be a "each/next"-statement that could do the trick - but I am a newbee. Are there someone out there who could help me write a more efficient code that:
1 ) scans the used styles in the document
2 ) pass them to a userform (whith names )
3) when checkbox is pressed - the dependent style is toggles its visible/not visible status?
The styles I uses now are:
- Sceneheading (numbered) (Should always be visible)
- Character/Dialogue (which is actually two different styles - but they have to show up at the same time)
Maybe with the ability to change styles easy - and fire the same code?
Thank you so much in advance.
A little snippet of code from my UserForm ("Visalle" means "Show all")
Private Sub Admin_Change() If Admin.Value = False Then ActiveDocument.Styles("Admin").Font.Hidden = True ElseIf Admin.Value = True Then ActiveDocument.Styles("Admin").Font.Hidden = False End If selvtest End Sub Private Sub selvtest() Dim ctl As Control Dim j As Long Dim msg As String For Each ctl In Me.Controls If TypeOf ctl Is MSForms.CheckBox Then If Me.Controls(ctl.Name).Value = True Then j = j + 1 End If End If Next If j <> 6 Then Me.Visalle.Value = False Else If Me.Visalle.Value = True Then Me.Visalle.Value = False Else Me.Visalle.Value = True End If End If End Sub