![]() |
|
#2
|
||||
|
||||
|
Here's one I prepared earlier...
Code:
Sub InsertAllStyleSamples()
'Inserts samples of all present style entries into the current file
Dim sStyle As Style, sText As String, oTbl As Table
Dim rngChars As Range, rngParas As Range, rngTables As Range, rngLists As Range
sText = " - The quick brown fox jumped over the lazy dog. " & _
"12345 67890 The quick brown fox jumped over the lazy dog."
For Each sStyle In ActiveDocument.Styles
'If sStyle.Locked = False Then
'If sStyle.Priority > 4 And sStyle.Priority < 50 Then
Select Case sStyle.Type
Case wdStyleTypeCharacter
Selection.Style = "Normal" 'the base paragraph style
Selection.Style = sStyle 'the character style
Selection.TypeText sStyle & " - character style" & vbCr
Selection.Font.Reset
Case wdStyleTypeList
'do nothing
Case wdStyleTypeParagraph
Selection.Style = sStyle 'the style
Selection.TypeText sStyle & sText & vbCr
Case wdStyleTypeTable
If sStyle.Visibility = False Then 'only if style is visible
Set oTbl = ActiveDocument.Tables.Add(Selection.Range, 3, 3)
With oTbl
oTbl.Style = sStyle 'the table style
oTbl.Range.Style = "Table Text" 'the paragraph style (will fail if style doesn't exist)
oTbl.Rows(1).Range.Style = "Table Heading"
oTbl.cell(1, 1).Range.Text = sStyle & " - Table Style"
oTbl.cell(2, 1).Range.Text = "Table Text Paragraph Style"
oTbl.cell(3, 1).Range.Text = Mid(sText, 4, 15)
oTbl.cell(1, 2).Range.Text = "Table Heading Paragraph Style"
oTbl.cell(2, 2).Range.Text = Mid(sText, 4, 15)
oTbl.cell(3, 2).Range.Text = Mid(sText, 4, 15)
oTbl.cell(1, 3).Range.Text = Mid(sText, 4, 15)
oTbl.cell(2, 3).Range.Text = Mid(sText, 4, 15)
oTbl.cell(3, 3).Range.Text = Mid(sText, 4, 15)
End With
oTbl.Range.Select
Selection.MoveDown
Selection.TypeText vbCr
End If
'do nothing
End Select
'End If
Next sStyle
End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
| Tags |
| style list, template document styles, vba code |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Find several words in document, copy paragraph and create new document
|
coolio2341 | Word VBA | 6 | 01-31-2019 01:17 PM |
| Does a new set of styles in a template overwrite or remove the existing set of styles in a document? | dianahbr | Word | 6 | 03-27-2018 11:12 PM |
| Single step Word Styles from Source Document through entire Destination document? | xbliss | Word | 6 | 08-27-2016 09:36 PM |
Word 2010 - How to create a fillable document from a boilerplate document
|
sheaters | Word | 2 | 05-04-2016 01:57 PM |
| document styles and some formatting doesn't appear where should when different people view document | Dilbert fan | Word | 1 | 08-23-2015 05:07 AM |