I have a simple script that goes through and sets the style for all paragraphs beginning with a certain character. Easy, I thought. It changes all the paragraphs so they have the same properties as the "Details" Style. But for some reason only the last paragraph ends up with "Details" as its style and all the ones before go back to "Normal". Here's my code so far:
Sub Format_doc()
Dim txt As String
For Each par In ActiveDocument.Paragraphs
txt = par.Range.Text
If Left(txt, 1) = "/" Then
par.Style = "Details"
par.Range.Text = Right(txt, Len(txt) - 1)
End If
Next
End Sub
I'd like to keep them attached to the style because I toggle the "hidden" font property in another macro. I'll need to toggle this hidden property for these paragraphs on-and-off several times and assigning a single paragraph style seemed like an easy solution. Here's the other code:
Sub Toggle_hidden()
ActiveDocument.Styles("Details").Font.Hidden = Not ActiveDocument.Styles("Details").Font.Hidden
End Sub
Solutions? I'm working on Mac, but ultimately this will end up on a Windows.