Consulting

Results 1 to 6 of 6

Thread: Keyboard

  1. #1
    VBAX Contributor
    Joined
    May 2007
    Posts
    128
    Location

    Keyboard

    Dear Sir,
    I want to hide msgbox with keyboard command but msgbox does not displayed. What is wrong? please modify codes

    [vba]
    Sub Oval1_Click()
    MsgBox ("yes")
    Application.OnKey "+^{Enter}"
    End Sub
    [/vba]

  2. #2
    Administrator
    2nd VP-Knowledge Base
    VBAX Master malik641's Avatar
    Joined
    Jul 2005
    Location
    Florida baby!
    Posts
    1,533
    Location
    Hi tqm1,

    The message that you used in your code is written correctly. And the user can simply press Enter, Escape, or Space bar to close ('hide') it.

    What exactly are you trying to accomplish with the Application.OnKey method? In your code you are resetting the key combination Shift+Ctrl+Enter to whatever the default is (if one exists....), you are not setting the key combination to a macro.

    And from the title of your procedure, it looks like you are trying to click a shape object and run the macro. In this case, you should make sure your macro is within a Standard Module, not a sheet module. If that doesn't work, try right-clicking the Oval shape again and re-assigning the macro to it. Please let us know.

    Hope this helps




    New to the forum? Check out our Introductions section to get to know some of the members here. Feel free to tell us a little about yourself as well.

  3. #3
    VBAX Contributor
    Joined
    May 2007
    Posts
    128
    Location
    Dear Sir,

    When I press OVAL then messagebox must disappear.

    To press Enter key, in Visualfoxpr I use as
    keyboard "{enter}"
    This command Press Enter key

    Please help again

  4. #4
    Administrator
    2nd VP-Knowledge Base VBAX Master malik641's Avatar
    Joined
    Jul 2005
    Location
    Florida baby!
    Posts
    1,533
    Location
    tqm1,

    When there is a message box loaded, a user cannot press anything else in Excel until the message box is closed. This is because the standard message box (MsgBox) is not a Modeless form. If what you are trying to do is display a message and close it by the user pressing an oval shape, then you need to create your own message box using a Userform. Make sure the ShowModal property is set to False.


    I believe there's a little bit of a language barrier, which is no problem at all. But I think the best thing to do is for you to provide an example workbook with what you are trying to accomplish and I'm sure we can give you an answer much faster. I know it's 7:45 AM for you right now, but it's kind of late for me tonight (10:43 PM) and I'm heading to bed. I will try to help you tomorrow night (same time for you ...around 7:45 AM). Maybe somebody will have your answer by then. Who knows?

    Until then, good night (or for you, good morning )




    New to the forum? Check out our Introductions section to get to know some of the members here. Feel free to tell us a little about yourself as well.

  5. #5
    VBAX Contributor
    Joined
    May 2007
    Posts
    128
    Location
    For more ease

    How to hide messagebox after one second?
    Last edited by tqm1; 07-31-2007 at 09:22 PM.

  6. #6
    VBAX Master geekgirlau's Avatar
    Joined
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,464
    Location
    As Joseph explained, the MsgBox is modal in Excel, which means that nothing else will happen until the user responds to the message. If you want a message that you can get rid of in some other way (like clicking on an object or after a set period of time) you need to create a userform instead - MsgBox will not do what you want.

Posting Permissions

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