Share via

How can I get word to prompt the user with a yes or no question?

Anonymous
2011-10-12T20:33:38+00:00

I want the user to answer yes or no only. If they answer yes word inserts a line of text, if they answer no nothing is inserted.

This needs to be able to be saved as a Microsoft 97-2003 document and opened in multiple versions of word.

Thanks!

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

  1. Anonymous
    2011-10-13T19:05:04+00:00

    I realize that I am Johnny come late, but this has got to have become the most convoluted thread to be such a simple task and illustrates why it is always helpful to fully explain the objective up front.

    If you can use a table then you don't need a bookmark or a texbox or anything else.  Tables by there very nature are nice little compact range targets.  All you have to do is point to them.

    AutoExec fires when Word is launched.  If you want the code to run when the document opens then use a Document_Open in the ThisDocument module or use a AutoOpen procedure in a standard template module.

    Tables are "index" with where they appear in a document.  If you have one table then it is index as "1"

    Sub Document_Open()

    If MsgBox("Charge Short Term Lease Fee?", vbQuestion + vbYesNo, "Input") = vbYes Then

      ActiveDocument.Tables(1).Cell(2, 2).Range.Text = "Short Term Lease Lease Fee $20.00"

    End If

    End Sub

    Note:  Cell(2,2) points to the second row, second column cell

    1 person found this answer helpful.
    0 comments No comments

18 additional answers

Sort by: Most helpful
  1. Anonymous
    2011-10-13T16:02:33+00:00

    Ok after doing some readng maybe I didn't specifiy my question well enough. I want this pop up message box to open when the document opens. Then they answer the yes or no question. If they answer yes it will insert a line of text into a specifice area of the document. If they answer no nothing happens.

    Thanks!

    0 comments No comments
  2. Anonymous
    2011-10-13T15:42:54+00:00

    Ok I realize I may be talking to myself, but so far I think I figured out it need to be added as a Macro? So I created it there. When I click run it pops up the box with question I want, but when I click yes nothing happens. How do I tell it where to insert the line of text?

    Sorry I've never used Macros before and know no coding at all so I'm taking baby steps here.

    Thanks!

    0 comments No comments
  3. Anonymous
    2011-10-13T14:39:09+00:00

    You can use a MessageBox statement:

     

    msg = MsgBox("Do you want to insert the text", vbQuestion + vbYesNo, "Input")

    If msg = vbYes Then

        'insert line

    End If

    Ok, I guess this may be above my knowledge level. Where would I enter this? I don't see MessageBox as an input field in word.

    Thanks!

    0 comments No comments
  4. Anonymous
    2011-10-13T06:35:38+00:00

    You can use a MessageBox statement:

    msg = MsgBox("Do you want to insert the text", vbQuestion + vbYesNo, "Input")

    If msg = vbYes Then

        'insert line

    End If

    0 comments No comments