Share via

Reply dialog box with Excel VB

Pablo L. Gamarra 1 Reputation point
2021-08-18T13:30:14.513+00:00

Good estimates, my problem is the following I am trying to automate a cell phone recharge process with Excel the problem that arose is that when the code clicks on the accept button a dialog window is displayed asking if you want to do that recharge to that specified number and with the accept or cancel buttons, this in the vb code I get a warning that says "the object or class does not support the set of events", I think it is because I have to declare the dialog window As an object but I don't know how, if someone can give me help I would be very grateful.

Greetings!

ps: I have attached an image of the dialog window so you can understand it better124312-recarga.png

Community Center | Not monitored
0 comments No comments

3 answers

Sort by: Most helpful
  1. Gabriel Dzsurdzsa 6 Reputation points
    2021-08-25T16:50:03.377+00:00

    The MsgBox object comes with Excel, you don't need to construct it. What you would need to do is capture the result of the choice the user makes, and execute your code accordingly.

    For a function on how to store MsgBoxResult as an object. Read up on:

    vba-choice-messagebox

    Public Function Prompt()
    
        Dim Choice As VbMsgBoxResult
    
      'Store the message result object
      Choice = MsgBox("Ask the user a question?", vbQuestion + vbYesNo)
    
        Select Case Choice
    
            Case vbYes
    
                'Return something in the function
                Prompt = 1
    
            Case vbNo
    
                'Return something in the function
                Prompt = 0
    
        End Select
    
    End Function
    

    Was this answer helpful?

    0 comments No comments

  2. Pablo L. Gamarra 1 Reputation point
    2021-08-18T13:46:40.043+00:00

    Reformulate the question: Good estimates, my problem is the following I am trying to automate a cell phone recharging process with Excel the problem that arises is that when the code clicks on the accept button a dialog window is displayed asking if it is wants to do that reload to that specified number and with the accept or cancel buttons, this in the vb code I get a warning that says "the object or class does not support the set of events", I think it is because I have to declare The dialog window as an object but I don't know how, if someone can give me a help I would be very grateful.

    Greetings!

    ps: I have attached an image of the dialog window so you can understand it better!

    Was this answer helpful?

    0 comments No comments

  3. Anonymous
    2021-08-18T13:40:17.69+00:00

    Q&A forums are currently English only. I'd try asking for help over here in dedicated forums.
    https://social.msdn.microsoft.com/Forums/es-es/home
    https://social.technet.microsoft.com/Forums/es-es/home
    https://answers.microsoft.com/es-es

    --please don't forget to upvote and Accept as answer if the reply is helpful--

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.