Results 1 to 2 of 2
  1. #1
    3 Star Lounger
    Join Date
    Mar 2003
    Elkins Park, Pennsylvania, USA
    Thanked 0 Times in 0 Posts

    Protected docs and doc info (Word XP)

    Hi. Does anyone know why the following bit of code won't run on a protected document? Working around it (i.e. unlocking the doc temporarily) isn't really a big deal, but I'd rather not if I don't have to, especially if I'd have to do it repeatedly.

    Set hRange = Selection.Range.GoToPrevious(wdGoToHeading)
    hText = hRange.Paragraphs.First.Range.Text
    hNumber = hRange.ListFormat.ListString
    MsgBox "Current heading: " & hNumber & " " & hText

    (By the way, what I mean by "won't run" is that the code is supposed to return the text of the nearest preceding heading, but if the document is protected, it returns the text of the current paragraph instead.)

    <font face="Comic Sans MS">That's what you do in a herd; you look out for each other!</font face=comic> - Mike

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 30 Times in 30 Posts

    Re: Protected docs and doc info (Word XP)

    If you select Edit | Go To in a protected document, you will notice that it lists fewer items to go to than in an unprotected document. 'Heading' is one of the options that is not available in a protected document. So you must either unprotect the document, or write your own code to move up paragraph by paragraph until you encounter a heading.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts