+ Reply to Thread
Results 1 to 2 of 2

OnKey Method

  1. #1
    Registered User
    Join Date
    06-03-2005
    Posts
    16

    Question OnKey Method

    I need help with the onkey method. I can not get it to work.

    I have created a userform, label and macro named UserForm1, lblPress, and Functest respectively. Here is my code. What am I doing wrong?

    Private Sub UserForm_Initialize()
    Application.OnKey "{F10}", "functest"
    End Sub
    ----------------------------------------------------------------------
    Private Sub UserForm_Terminate()
    Application.OnKey "{F10}"
    End Sub
    ----------------------------------------------------------------------
    Sub functest()
    Const conMsg As String = "You have pressed F10"

    lblPress.Caption = conMsg

    End Sub

  2. #2
    Gary's Student
    Guest

    RE: OnKey Method

    Its hard to advise here, but:

    1. make sure your stuff is in the ThisWorkbook module
    2. you might need private sub workbook_open() to do the initialization
    --
    Gary's Student


    "Tha BeatMaker" wrote:

    >
    > I need help with the onkey method. I can not get it to work.
    >
    > I have created a userform, label and macro named UserForm1, lblPress,
    > and Functest respectively. Here is my code. What am I doing wrong?
    >
    > Private Sub UserForm_Initialize()
    > Application.OnKey "{F10}", "functest"
    > End Sub
    > ----------------------------------------------------------------------
    > Private Sub UserForm_Terminate()
    > Application.OnKey "{F10}"
    > End Sub
    > ----------------------------------------------------------------------
    > Sub functest()
    > Const conMsg As String = "You have pressed F10"
    >
    > lblPress.Caption = conMsg
    >
    > End Sub
    >
    >
    > --
    > Tha BeatMaker
    > ------------------------------------------------------------------------
    > Tha BeatMaker's Profile: http://www.excelforum.com/member.php...o&userid=23998
    > View this thread: http://www.excelforum.com/showthread...hreadid=397499
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1