Consulting

Results 1 to 12 of 12

Thread: Solved: Onkey

  1. #1
    VBAX Regular Mandy's Avatar
    Joined
    Jun 2007
    Posts
    30
    Location

    Solved: Onkey

    Hi

    i have a problem. first look the following code.

    [VBA]
    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
    [/VBA]


    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

  2. #2
    VBAX Contributor
    Joined
    Aug 2006
    Location
    Hampshire, UK
    Posts
    140
    Location
    Hi Mandy

    These subs:

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

    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

  3. #3
    VBAX Regular Mandy's Avatar
    Joined
    Jun 2007
    Posts
    30
    Location
    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

  4. #4
    VBAX Contributor
    Joined
    Aug 2006
    Location
    Hampshire, UK
    Posts
    140
    Location
    Have you saved down the workbook and re-opened it?

    Richard

  5. #5
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Post the workbook, it should be okay.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by RichardSchol
    Have you saved down the workbook and re-opened it?

    Richard
    No need, moving it should be sufficient.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  7. #7
    VBAX Regular Mandy's Avatar
    Joined
    Jun 2007
    Posts
    30
    Location
    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

  8. #8
    VBAX Regular Mandy's Avatar
    Joined
    Jun 2007
    Posts
    30
    Location
    yes i had saved and reopend again but nothing happen.

  9. #9
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    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.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  10. #10
    VBAX Regular Mandy's Avatar
    Joined
    Jun 2007
    Posts
    30
    Location

    onkey workbook

    here is the workbook

  11. #11
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    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?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  12. #12
    VBAX Regular Mandy's Avatar
    Joined
    Jun 2007
    Posts
    30
    Location

    solved

    Yesssssss

    sir u fixed the problem

    Thanks

Posting Permissions

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