Has anyone ever encountered a paragraph that had no style applied before? I was troubleshooting a co-worker’s document that was tripping up on one of my macros, and I traced the problem to a line that was testing the paragraph style type, as in:
If para.Style.Type = wdStyleTypeCharacter Then
The error was “Block or Object Variable not set”
After scratching my head a bit, I went back to the document, and noticed that in the styles pulldown on the Formatting toolbar, there was nothing. Tried Ctrl-Q, and even Ctrl-Space, and still nothing.
With the cursor in the offending paragraph, I went back to the VBA IDE, and in the immediate window, tried:
?Selection.Range.Paragraphs.First.Style.Type
And I got the same error message about an object variable not being set.
Re-applying the paragraph style resolved the problem, but it was such a strange thing that I wondered if anyone ever encountered that before, and if so, had any insight into why/when it happens.