Results 1 to 5 of 5
  1. #1
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Message Box Response (XP)

    I have a typical message box written in code and would like to be able to have the code select YES. I have tried using Application.DisplayAlerts = True but this does not work on the message box.

    Response = MsgBox(Msg, DialogStyle, Title)
    If Response = vbYes Then
    Run some code for yes response
    End If

    If Response = vbNo Then
    Run some code for a NO response
    End if


    Your assistance is appreciated,
    John

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Message Box Response (XP)

    If you want the code to select Yes, why display a message box at all?

    Please try to explain more clearly what you want to accomplish.

  3. #3
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Message Box Response (XP)

    I have code that an EndUser would need to select "Yes or No" from the message box. I would like to run the code upon Auto_Open if I were to schedule a task to open the Excel file. Based upon the Environ("ComputerName") the code would proceed to automatically respond to "Yes".

    I know I could write additional code but am looking for a cleaner solution.

    Regards,
    John

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Message Box Response (XP)

    I'd do something like this:

    Sub CodeForYes()
    ' Run some code for yes response
    End Sub

    Sub CodeForNo()
    ' Run some code for a NO response
    End Sub

    Use like this in your existing code:

    Response = MsgBox(Msg, DialogStyle, Title)
    Select Case Response
    Case vbYes
    Call CodeForYes
    Case vbNo
    Call CodeForNo
    End Select

    And use

    Call CodeForYes

    in your Auto_Open macro. This way, you don't have to duplicate code.

  5. #5
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Message Box Response (XP)

    Hans,

    I understand.

    Many thanks,
    John

Posting Permissions

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