+ Reply to Thread
Results 1 to 7 of 7

Onkey method

  1. #1
    Fishingsantafe
    Guest

    Onkey method

    How do you assign a short cut key to a macro I created. I am tryin to learn
    VBA and am working on writing code. I have been reading about the onkey
    method. Where in the code to you enter the short cut key? After the Dim
    Statement?

    Could some one give me a couple of easy examples or tell where I can find
    the code or symbols used for short cut keys? What happens if I use a key
    that is already assigned to do something else? Can it recognize when to use
    it to run a macro and when to use it for it original purpose?

    I am just learning VBA and trying to learn to code macros. I have manged to
    code and edit the macro to get it to do what I wanted but can not seem to
    figure out how to attach a short cut key in the code.

    Also does anyone know if there is a way to create macros in Excel and use
    them in another application that uses VB? How do you tie the two together?

    Any help is appreciated.

  2. #2
    Dave Peterson
    Guest

    Re: Onkey method

    You can assign a shortcut key via:

    Tools|macro|macros...
    select your macro from the list
    then click options

    I'd suggest a combination of ctrl-shift-(letter) to stay away from built in
    shortcuts.

    Alternatively, you can dump the shortcut keys and use menus/toolbars to invoke
    your macros.

    If you want to add an option to the worksheet menu bar, I really like the way
    John Walkenbach does it in his menumaker workbook:
    http://j-walk.com/ss/excel/tips/tip53.htm

    Here's how I do it when I want a toolbar:
    http://www.contextures.com/xlToolbar02.html
    (from Debra Dalgleish's site)

    ======
    And your second question has a few answers. If the other application can be
    automated (like MSWord/Powerpoint/outlook/others that support VBA(????), you can
    do it fine. (Well, if you know that other application well enough to write a
    useful macro.)

    If the other application doesn't support automation, then maybe you could use
    Sendkeys to control it (maybe unreliable).

    If you have a more specific question, I'm sure you'll get a better answer.

    Fishingsantafe wrote:
    >
    > How do you assign a short cut key to a macro I created. I am tryin to learn
    > VBA and am working on writing code. I have been reading about the onkey
    > method. Where in the code to you enter the short cut key? After the Dim
    > Statement?
    >
    > Could some one give me a couple of easy examples or tell where I can find
    > the code or symbols used for short cut keys? What happens if I use a key
    > that is already assigned to do something else? Can it recognize when to use
    > it to run a macro and when to use it for it original purpose?
    >
    > I am just learning VBA and trying to learn to code macros. I have manged to
    > code and edit the macro to get it to do what I wanted but can not seem to
    > figure out how to attach a short cut key in the code.
    >
    > Also does anyone know if there is a way to create macros in Excel and use
    > them in another application that uses VB? How do you tie the two together?
    >
    > Any help is appreciated.


    --

    Dave Peterson

  3. #3
    David McRitchie
    Guest

    Re: Onkey method

    And in answer to still another part of your question:
    If you assign a shortcut you will override the default usage.
    To help you recognize existing shortcuts see
    http://www.mvps.org/dmcritchie/excel/shortx2k.htm
    ---
    HTH,
    David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
    My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
    Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

    > Fishingsantafe wrote:
    > > Could some one give me a couple of easy examples or tell where I can find
    > > the code or symbols used for short cut keys? What happens if I use a key
    > > that is already assigned to do something else? Can it recognize when to use
    > > it to run a macro and when to use it for it original purpose?




  4. #4
    Fishingsantafe via OfficeKB.com
    Guest

    Re: Onkey method

    If I were to use the short cut keys lets say ctrl-shift-c how would write the
    code for this and would this fall right under the dim statement? I will look
    into the toolbar thing and if i have any question I will write

    Dave Peterson wrote:
    >You can assign a shortcut key via:
    >
    >Tools|macro|macros...
    >select your macro from the list
    >then click options
    >
    >I'd suggest a combination of ctrl-shift-(letter) to stay away from built in
    >shortcuts.
    >
    >Alternatively, you can dump the shortcut keys and use menus/toolbars to invoke
    >your macros.
    >
    >If you want to add an option to the worksheet menu bar, I really like the way
    >John Walkenbach does it in his menumaker workbook:
    >http://j-walk.com/ss/excel/tips/tip53.htm
    >
    >Here's how I do it when I want a toolbar:
    >http://www.contextures.com/xlToolbar02.html
    >(from Debra Dalgleish's site)
    >
    >======
    >And your second question has a few answers. If the other application can be
    >automated (like MSWord/Powerpoint/outlook/others that support VBA(????), you can
    >do it fine. (Well, if you know that other application well enough to write a
    >useful macro.)
    >
    >If the other application doesn't support automation, then maybe you could use
    >Sendkeys to control it (maybe unreliable).
    >
    >If you have a more specific question, I'm sure you'll get a better answer.
    >
    >> How do you assign a short cut key to a macro I created. I am tryin to learn
    >> VBA and am working on writing code. I have been reading about the onkey

    >[quoted text clipped - 14 lines]
    >>
    >> Any help is appreciated.

    >


    --
    Message posted via OfficeKB.com
    http://www.officekb.com/Uwe/Forums.a...l-new/200601/1

  5. #5
    Fishingsantafe via OfficeKB.com
    Guest

    Re: Onkey method

    Thanks for responding. I know this can be done with the application (I heard
    of someone else that did it) I just can not figure out how the two tie
    together. This application uses OLE Automation like excel does. I also
    coded a macro in this application a using VBA languabe and it worked just
    fine so I know it understands VBA. But if I record a macro in this
    application I can see It uses send keys when I go to edit.

    I just want to be able to record in excel some repetitive tasks that I do in
    this other application. I want to be able to use these macros that I
    recorded in excel in this other application.

    Dave Peterson wrote:
    >You can assign a shortcut key via:
    >
    >Tools|macro|macros...
    >select your macro from the list
    >then click options
    >
    >I'd suggest a combination of ctrl-shift-(letter) to stay away from built in
    >shortcuts.
    >
    >Alternatively, you can dump the shortcut keys and use menus/toolbars to invoke
    >your macros.
    >
    >If you want to add an option to the worksheet menu bar, I really like the way
    >John Walkenbach does it in his menumaker workbook:
    >http://j-walk.com/ss/excel/tips/tip53.htm
    >
    >Here's how I do it when I want a toolbar:
    >http://www.contextures.com/xlToolbar02.html
    >(from Debra Dalgleish's site)
    >
    >======
    >And your second question has a few answers. If the other application can be
    >automated (like MSWord/Powerpoint/outlook/others that support VBA(????), you can
    >do it fine. (Well, if you know that other application well enough to write a
    >useful macro.)
    >
    >If the other application doesn't support automation, then maybe you could use
    >Sendkeys to control it (maybe unreliable).
    >
    >If you have a more specific question, I'm sure you'll get a better answer.
    >
    >> How do you assign a short cut key to a macro I created. I am tryin to learn
    >> VBA and am working on writing code. I have been reading about the onkey

    >[quoted text clipped - 14 lines]
    >>
    >> Any help is appreciated.

    >


    --
    Message posted via OfficeKB.com
    http://www.officekb.com/Uwe/Forums.a...l-new/200601/1

  6. #6
    Dave Peterson
    Guest

    Re: Onkey method

    I'd assign the shortcut key manually, but you could use something like:

    Option Explicit
    Sub testme01()
    MsgBox "hi"
    End Sub
    Sub Enable()
    Application.OnKey Key:="^+c", procedure:="testme01"
    End Sub
    Sub Disable()
    Application.OnKey Key:="^+c", procedure:=""
    End Sub


    You could look at macrooptions in VBA's help, too.

    "Fishingsantafe via OfficeKB.com" wrote:
    >
    > If I were to use the short cut keys lets say ctrl-shift-c how would write the
    > code for this and would this fall right under the dim statement? I will look
    > into the toolbar thing and if i have any question I will write
    >
    > Dave Peterson wrote:
    > >You can assign a shortcut key via:
    > >
    > >Tools|macro|macros...
    > >select your macro from the list
    > >then click options
    > >
    > >I'd suggest a combination of ctrl-shift-(letter) to stay away from built in
    > >shortcuts.
    > >
    > >Alternatively, you can dump the shortcut keys and use menus/toolbars to invoke
    > >your macros.
    > >
    > >If you want to add an option to the worksheet menu bar, I really like the way
    > >John Walkenbach does it in his menumaker workbook:
    > >http://j-walk.com/ss/excel/tips/tip53.htm
    > >
    > >Here's how I do it when I want a toolbar:
    > >http://www.contextures.com/xlToolbar02.html
    > >(from Debra Dalgleish's site)
    > >
    > >======
    > >And your second question has a few answers. If the other application can be
    > >automated (like MSWord/Powerpoint/outlook/others that support VBA(????), you can
    > >do it fine. (Well, if you know that other application well enough to write a
    > >useful macro.)
    > >
    > >If the other application doesn't support automation, then maybe you could use
    > >Sendkeys to control it (maybe unreliable).
    > >
    > >If you have a more specific question, I'm sure you'll get a better answer.
    > >
    > >> How do you assign a short cut key to a macro I created. I am tryin to learn
    > >> VBA and am working on writing code. I have been reading about the onkey

    > >[quoted text clipped - 14 lines]
    > >>
    > >> Any help is appreciated.

    > >

    >
    > --
    > Message posted via OfficeKB.com
    > http://www.officekb.com/Uwe/Forums.a...l-new/200601/1


    --

    Dave Peterson

  7. #7
    Dave Peterson
    Guest

    Re: Onkey method

    If you post the name of the other application, you may get some specific help.

    I don't have a guess.

    "Fishingsantafe via OfficeKB.com" wrote:
    >
    > Thanks for responding. I know this can be done with the application (I heard
    > of someone else that did it) I just can not figure out how the two tie
    > together. This application uses OLE Automation like excel does. I also
    > coded a macro in this application a using VBA languabe and it worked just
    > fine so I know it understands VBA. But if I record a macro in this
    > application I can see It uses send keys when I go to edit.
    >
    > I just want to be able to record in excel some repetitive tasks that I do in
    > this other application. I want to be able to use these macros that I
    > recorded in excel in this other application.
    >
    > Dave Peterson wrote:
    > >You can assign a shortcut key via:
    > >
    > >Tools|macro|macros...
    > >select your macro from the list
    > >then click options
    > >
    > >I'd suggest a combination of ctrl-shift-(letter) to stay away from built in
    > >shortcuts.
    > >
    > >Alternatively, you can dump the shortcut keys and use menus/toolbars to invoke
    > >your macros.
    > >
    > >If you want to add an option to the worksheet menu bar, I really like the way
    > >John Walkenbach does it in his menumaker workbook:
    > >http://j-walk.com/ss/excel/tips/tip53.htm
    > >
    > >Here's how I do it when I want a toolbar:
    > >http://www.contextures.com/xlToolbar02.html
    > >(from Debra Dalgleish's site)
    > >
    > >======
    > >And your second question has a few answers. If the other application can be
    > >automated (like MSWord/Powerpoint/outlook/others that support VBA(????), you can
    > >do it fine. (Well, if you know that other application well enough to write a
    > >useful macro.)
    > >
    > >If the other application doesn't support automation, then maybe you could use
    > >Sendkeys to control it (maybe unreliable).
    > >
    > >If you have a more specific question, I'm sure you'll get a better answer.
    > >
    > >> How do you assign a short cut key to a macro I created. I am tryin to learn
    > >> VBA and am working on writing code. I have been reading about the onkey

    > >[quoted text clipped - 14 lines]
    > >>
    > >> Any help is appreciated.

    > >

    >
    > --
    > Message posted via OfficeKB.com
    > http://www.officekb.com/Uwe/Forums.a...l-new/200601/1


    --

    Dave Peterson

+ 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