Results 1 to 7 of 7
  1. #1
    New Lounger
    Join Date
    Dec 2009
    Location
    Philadelphia, PA
    Posts
    17
    Thanks
    1
    Thanked 0 Times in 0 Posts
    The document works fine under Word 2003. But it doesn't work under Word 2007.

    Basically, the user clicks a series of checkboxes to determine whether or not they did something, and then, at the bottom, there's a final checkbox. When clicked, a macro generates a second page with additional questions based upon the previously-checked boxes.

    Well, now, when clicked, run-time error 5224 appears at the line "Selection.TypeParagraph" of the following subroutine. Any thoughts?

    Public Sub BuildStQuestions()
    Selection.TypeParagraph
    Selection.InsertBreak Type:=wdPageBreak
    Selection.TypeText Text:="1. date of birth verified. "
    CreateYNDDL
    Selection.TypeParagraph
    Selection.TypeText Text:="2. ID number verified. "
    CreateYNDDL
    Selection.TypeParagraph
    Selection.TypeText Text:="3. Which state? "
    Selection.FormFields.Add Range:=Selection.Range, Type:= _
    wdFieldFormTextInput
    Selection.TypeParagraph
    Selection.TypeText Text:="4. Which city? "
    CreateYNDDL
    Selection.TypeParagraph
    Selection.TypeText Text:="5. Age? "
    CreateYNDDL
    Selection.TypeParagraph
    Selection.TypeText Text:="6. Assistant? "
    CreateYNDDL
    Selection.TypeParagraph
    Selection.TypeText Text:="7. Services? "
    CreateYNDDL
    Selection.TypeParagraph
    End Sub

  2. #2
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post
    Try replacing the offending line with
    Selection.TypeText Chr(13)
    Regards
    Don

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts
    Quote Originally Posted by Rob Skinner View Post
    Basically, the user clicks a series of checkboxes to determine whether or not they did something, and then, at the bottom, there's a final checkbox. When clicked, a macro generates a second page with additional questions based upon the previously-checked boxes.
    Are you unprotecting the document before modifying it? (Or is it not protected form forms?)

    If you check help, what does error 5224 mean?

  4. #4
    New Lounger
    Join Date
    Dec 2009
    Location
    Philadelphia, PA
    Posts
    17
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Don, thanks. Tried that statement, and it didn't work, either.

    JS, I unprotected the document, made Don's change, and, again, protected the document. No success.

    Here's something new: went into the Visual Basic editor, clicked at the start of this offending subroutine, clicked the Run button, and got the following error message: "This method or property is not available because the object refers to a protected area of the document." What does that mean?

  5. #5
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts
    Quote Originally Posted by Rob Skinner View Post
    Here's something new: went into the Visual Basic editor, clicked at the start of this offending subroutine, clicked the Run button, and got the following error message: "This method or property is not available because the object refers to a protected area of the document." What does that mean?
    You can't insert text into a protected section of the document, either by hand or by macro. When you re-protected, did you protect only the section with the form controls and leave the section where you insert text unprotected?

  6. #6
    New Lounger
    Join Date
    Dec 2009
    Location
    Philadelphia, PA
    Posts
    17
    Thanks
    1
    Thanked 0 Times in 0 Posts
    This document was created a long time ago, and its creator is gone. This all got passed down to me. From what I can tell: it opens as a one-page document. You check a few check boxes, click a final Yes or No check box at the bottom, and then a macro generates a second page (with additional questions about the previously-checked check boxes.) I've watched it work under Word 2003. But it just won't work under Word 2007. I'm thinking: are there any difference between 2003 and 2007, maybe in the syntax of the statements, that would prevent it from working under 2007?

  7. #7
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts
    Quote Originally Posted by Rob Skinner View Post
    I'm thinking: are there any difference between 2003 and 2007, maybe in the syntax of the statements, that would prevent it from working under 2007?
    Maybe. But there are some missing links. For example, before running the code you posted, does a different macro add a new section? Or does it unprotect and reprotect the document?

    If possible, please post a copy of the document/template (place it in a zip archive if it's a template), removing any confidential or personal information.

Posting Permissions

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