PDA

View Full Version : Keyboard



tqm1
07-31-2007, 06:53 PM
Dear Sir,
I want to hide msgbox with keyboard command but msgbox does not displayed. What is wrong? please modify codes


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

malik641
07-31-2007, 07:20 PM
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 :)

tqm1
07-31-2007, 07:26 PM
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

malik641
07-31-2007, 07:44 PM
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 :))

tqm1
07-31-2007, 08:03 PM
For more ease

How to hide messagebox after one second?

geekgirlau
07-31-2007, 09:55 PM
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.