Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.
Sub theStylist1() Dim Para As Paragraph Dim myForm As styleBox 'using a user form to select styles Dim rng As Range Dim rng2 As Range Dim paraLen As Long If MsgBox("Do you want to resume from the selection point", vbYesNo) = vbYes Then Set rng = Selection.Range rng.End = ActiveDocument.Range.End Else Set rng = ActiveDocument.Range End If Set myForm = New styleBox For Each Para In rng.Paragraphs 'Don't want to waste time on empty lines --> they can all be set to normal Set rng2 = Para.Range If Len(rng2.Text) = 1 Then Para.Style = "Normal" Else On Error GoTo errNoTable If rng2.Cells.Count = 1 Then If rng2.End = rng2.Cells(1).Range.End Then 'Avoid selecting the cell marker rng2.MoveEnd wdCharacter, -1 End If End If errNoTable: If Err = 5907 Then MsgBox Para.Style & " No Table, Please Check Document" Para.Style = "Normal" Resume errNextTable End If rng2.Select 'select to show paragraph to user paraLen = Selection.End - Selection.Start If paraLen = 1 Then Para.Style = "Normal" Else myForm.Caption = Para.Style myForm.Show Select Case myForm.Tag Case 99 Unload myForm Set myForm = Nothing Exit Sub Case 0 'do nothing Case 1 Para.Style = "Normal" Case 2 Para.Style = "TaskStep" Case 3 Para.Style = "Function" Case 4 Para.Style = "Sub-Step" Case 5 Para.Style = "SubStepBullet" Case 6 Para.Style = "Caution" Case 7 Para.Style = "Note" Case 8 Para.Style = "Task End" Case 9 Para.Style = "Task Name" Case 10 Para.Style = "Table Sub Heading" Case 11 Para.Style = "Procedure Title" Case 12 Para.Style = "TaskStep" Case 13 Para.Style = "Heading 1" Case 14 Para.Style = "Heading 2" Case 15 Para.Style = "Heading 3" End Select End If End If errNextTable: Next Para End Sub
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.