PDA

View Full Version : Solved: Problem in Application.OnKey Method



Erdin? E. Ka
11-11-2006, 04:51 PM
Hi,

I want to if activecell is not empty then activecell / 1,18 to activecell.
I can do it via directly runnig the codes below:

Sub KDV()
If ActiveCell.Value <> "" Then ActiveCell.Value = (ActiveCell.Value / 1.18)
End Sub

But my problem is, when i try to run KDV macro via keaborad shortcut for CTRL and i doing noting.

What should i do for assign KDV macro to a binary keyboard shortcut combination? For example, CTRL and F12 or CTRL and G... something like this...

My ThisWorkbook codes as below:


Sub Auto_Open()
Application.OnKey "^i", "KDV" ' Ctrl & i combination
End Sub



Sub Auto_Close()
Application.OnKey "^i", ""
End Sub


Thank you very much.

Erdin? E. Ka
11-11-2006, 05:18 PM
Now, i solved my problem. Thanks.:hi:

SamT
11-11-2006, 07:37 PM
How did you solve it?
SamT

Erdin? E. Ka
11-11-2006, 08:44 PM
I moved Auto_Open and Auto_Close procedures to Module1. Then i closed Excel application. And re opened the book. And i tried again to run. Finally it worked well.

Ken Puls
11-12-2006, 11:43 AM
Hi Erdinc,

For reference, Auto_Open and Auto_Close are old syntaxs that have been hanging around a while. Common practice is to use Workbook_Open and Workbook_Close events that are located in the ThisWorkbook module.

I don't believe that there is any ill effect by choosing either way, but just thought I'd mention it.

:)

Bob Phillips
11-12-2006, 12:56 PM
For reference, Auto_Open and Auto_Close are old syntaxs that have been hanging around a while. Common practice is to use Workbook_Open and Workbook_Close events that are located in the ThisWorkbook module.

I don't believe that there is any ill effect by choosing either way, but just thought I'd mention it.

Yes there is.

Auto_Open doesn't run if opened from within another piece of code or automation.

Ken Puls
11-12-2006, 05:43 PM
Ah, well there you go. Thanks, Bob! :)

I've never actually had the need to structure a solution to make use of that yet. Good to know. :yes