PDA

View Full Version : Solved: Onkey



Mandy
07-02-2007, 02:33 AM
Hi:hi:

i have a problem. first look the following code.


Private Sub Workbook_Open()
Call Keyworks
End Sub

Sub Keyworks()
Application.OnKey "{down}", "message"
End Sub
Sub message()
MsgBox "Can Some one Help Me!"
End Sub



according to this code when this workbook open next time, and if i press down key it should show the message(can some one help me).

but i am getting error message that is given below.

The Macro "c:\Documents and Settings\My Docuements\VBA.xls'!message' cannot be found.

what this indicates.
can any one tell me how i can show the message by pressing the down key.

Thanks

RichardSchollar
07-02-2007, 02:42 AM
Hi Mandy

These subs:

Sub Keyworks()
Application.OnKey "{down}", "message"
End Sub
Sub message()
MsgBox "Can Some one Help Me!"
End Sub

Need to be located in a standard module, not in the ThisWorkbook module - so insert a standard one, and cut them from ThisWorkbook and paste them into the standard. It should then work.

Richrd

Mandy
07-02-2007, 03:01 AM
hi
i did but now nothing is happening.
not any error msg , and not the acctual msg that i want to display.
that mean nothing happens when i press the down key.
plz help

Thanks

RichardSchollar
07-02-2007, 03:05 AM
Have you saved down the workbook and re-opened it?

Richard

Bob Phillips
07-02-2007, 03:06 AM
Post the workbook, it should be okay.

Bob Phillips
07-02-2007, 03:07 AM
Have you saved down the workbook and re-opened it?

Richard

No need, moving it should be sufficient.

Mandy
07-02-2007, 03:16 AM
hello sir
sory i dont know how to post the workbook.
can u tell me.
plz

there is nothing more in the workbook.
3 sheets blank.
in the module the above code is wirtten. that's all



thanks

Mandy
07-02-2007, 03:17 AM
yes i had saved and reopend again but nothing happen.

Bob Phillips
07-02-2007, 04:28 AM
Maybe, but seeing the workbook shows us exactly what you have.

If you hit the Go Advanced button when replying, scroll down to ADditional options, and you will see a button for Manage Attachments.

Mandy
07-02-2007, 04:33 AM
here is the workbook

Bob Phillips
07-02-2007, 04:43 AM
The workbook_open code goes in the ThisWorkbook module, the other two subs go in the general module.

See what a difference seeing it makes?

Mandy
07-02-2007, 04:56 AM
Yesssssss :beerchug:

sir u fixed the problem:thumb

Thanks:clap: