• Paragraph without a style (2002)

    Author
    Topic
    #406365

    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. confused
    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.

    Viewing 1 reply thread
    Author
    Replies
    • #842092

      Hi Andrew,

      It’s probably caused by an undocumented feature: You can hide styles in Word (ActiveDocument.Styles(“XY”).Hidden=True).

      In previous versions, I think you were able to just go into the paragraph and use “Selection.Style.Hidden=False”. But it doesn’t seem to work any more in Word2002/2003.

      If you save in HTML format and reopen, the style(s) should re-appear.

      cheers Klaus

      • #842098

        Very interesting, Klaus. Thank you.

        However, my problem only affected a single paragraph that used the style (it was the Normal style), and not the rest of the paragraphs that shared the style.

        When making a style hidden using the undocumented feature you described, all paragraphs using that style exhibit the same “missing style” behavior, and the style no long appears at all in the Style Area Width. Neither was the case with my coworker’s document.

        Thank you for your insight.

        • #842502

          Hi Andrew,

          If it’s possible, could you strip the document down a bit and post it here? Or mail it to me privately?
          I’d love to have a look at it.

          I had quite a few problems with my old Word97/2000 macros in Word2002/2003 because of the new list and table styles.
          A few times, I had to replace Range.Style or Selection.style with a loop through all styles, picking out the paragraph or character style.
          Which slows down already slow macros quite considerably frown

          But I can’t quite see how the list and table styles might cause the problem you see.

          cheers Klaus

        • #842503

          Hi Andrew,

          If it’s possible, could you strip the document down a bit and post it here? Or mail it to me privately?
          I’d love to have a look at it.

          I had quite a few problems with my old Word97/2000 macros in Word2002/2003 because of the new list and table styles.
          A few times, I had to replace Range.Style or Selection.style with a loop through all styles, picking out the paragraph or character style.
          Which slows down already slow macros quite considerably frown

          But I can’t quite see how the list and table styles might cause the problem you see.

          cheers Klaus

    • #842093

      Hi Andrew,

      It’s probably caused by an undocumented feature: You can hide styles in Word (ActiveDocument.Styles(“XY”).Hidden=True).

      In previous versions, I think you were able to just go into the paragraph and use “Selection.Style.Hidden=False”. But it doesn’t seem to work any more in Word2002/2003.

      If you save in HTML format and reopen, the style(s) should re-appear.

      cheers Klaus

    Viewing 1 reply thread
    Reply To: Paragraph without a style (2002)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: