PC Review


Reply
Thread Tools Rate Thread

Conditional application.onkey in realtime?

 
 
Andy
Guest
Posts: n/a
 
      22nd Mar 2007
Is there a way to use application.onkey to assign the same key to one
macro in workbookA and another Macro in workbookB? And have that same
shortcut key do nothing in WorkbookC? All three workbooks are open at
the same time so I want the appropriate macro to run in the active
workbook.

I tried a few ways making the application.onkey statement conditional
on the activeworkbook, but when the key was assigned, that was that.

TIA,

Andy


 
Reply With Quote
 
 
 
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      22nd Mar 2007
Use one macro assigned to the key combination.

have it check which workbook is active and take the appropriate action.

the alternative is to use the window activate event to reassign the onkey.

--
Regards,
Tom Ogilvy


"Andy" wrote:

> Is there a way to use application.onkey to assign the same key to one
> macro in workbookA and another Macro in workbookB? And have that same
> shortcut key do nothing in WorkbookC? All three workbooks are open at
> the same time so I want the appropriate macro to run in the active
> workbook.
>
> I tried a few ways making the application.onkey statement conditional
> on the activeworkbook, but when the key was assigned, that was that.
>
> TIA,
>
> Andy
>
>
>

 
Reply With Quote
 
Andy
Guest
Posts: n/a
 
      22nd Mar 2007
> Use one macro assigned to the key combination.
>
> have it check which workbook is active and take the appropriate action.


I should have been able to figure this out for myself! I'm sure I can get
this to work if I only have one workbook where I want the key combination to
work and don't want it to work anywhere else. This is the situation I'm
dealing with now, so this will solve my problem.

Not sure if I can make it work if I want the same key combo to work in two
workbooks and do different things in each, with each workbook having no idea
if a conflicting workbook is open, or what the name of that workbook is.
Each would have a workbook_open macro to assign the key and whichever one
opened last would override the other.

> The alternative is to use the window activate event to reassign the onkey.


I fooled with this a little, but I couldn't make it unassign when I moved to
another window. In most windows I want the key to be inert, and I never know
what other windows will be open.

I'll fool with these options and post back with better questions.

Thanks,

Andy





 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Application.Onkey John Microsoft Excel Programming 2 17th Dec 2009 08:17 PM
Application.OnKey iamnu Microsoft Excel Discussion 1 26th Mar 2009 01:58 PM
Application.Onkey for ^F not working Roopa Microsoft Excel Programming 2 11th Dec 2008 08:30 PM
How to apply Application.OnKey dewanna Microsoft Excel Programming 1 7th Apr 2006 07:16 AM
Application.OnKey Kevin H. Stecyk Microsoft Excel Programming 1 27th Jan 2005 01:26 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:30 AM.