Results 1 to 2 of 2
2003-05-16, 13:41 #1
- Join Date
- Apr 2003
- Kansas City, Missouri
- Thanked 0 Times in 0 Posts
What causes a paragraph's style to be Nothing? (Word 97/SR2 and Word 2000)
Hello. I am programmatically checking a document's styles paragraph by paragraph and returning a report if Heading styles are applied to table cells or page breaks.
For the most part, the code works fine. The beginning of the loop is:
For Each para In docCurrent.Paragraphs
Select Case para.Range.Style
Case "Heading 1", "Heading 2", "Heading 3", "Heading 4", "Heading 5", _
"Heading 6", "Heading 7", "Heading 8", "Heading 9", "Table Title", _
Usually, this works fine. I have been shown a sample document where it doesn't work. After some error trapping and whittling things down, I discovered that a paragraph, which has a style of Normal shows up as Nothing in VBA. I hover over the para.Range.Style and see that the style is Nothing. This causes my code to bomb.
I tried to bypass this by having
If para.Range.Style <> Nothing
but apparently, VBA doesn't like Nothing being used that way.
From a VBA POV, how can I trap a "Nothing" paragraph?
From a Word POV, what causes a paragraph to have no style? I'm sure this is a problem only for VBA, but I want to see if anyone else has this sort of problem. Furthermore, the problem happens when I have a document attached to the template. If I run the code on the template itself, the error does not show.
I appreciate any insight into this. I am cross-posting this to VBA.
2003-05-16, 14:32 #2
- Join Date
- Mar 2002
- Thanked 30 Times in 30 Posts
Re: What causes a paragraph's style to be Nothing? (Word 97/SR2 and Word 2
To avoid duplicate discussions, please reply to the thread in VBA, starting with <post#=254776>post 254776</post#>. I'm locking this thread.