Sunday, 15 January 2012

excel - Application.OnKey only for one spreadsheet -



excel - Application.OnKey only for one spreadsheet -

i trying utilize application.onkey start function when come in pressed, , works fine. problem if have additional spreadsheets open applied these well. should set code works intended spreadsheet?

this code, have in "thisworkbook":

private sub workbook_open() application.onkey "~", "set_hyper" application.onkey "{enter}", "set_hyper" end sub

heres way around it:

private sub workbook_open() application.onkey "~", "call_hyper" application.onkey "{enter}", "call_hyper" end sub

in module place this:

sub call_hyper if activeworkbook.name = "name of workbook" phone call set_hyper else exit sub end if end sub

if same shortcut needed workbook 2 cause problems, can deactivate when switching workbooks next too:

private sub workbook_deactivate() application.onkey "~" application.onkey "{enter}" end sub

you need alter first macro private sub workbook_activate() instead of private sub workbook_open() above work though

excel vba excel-vba

No comments:

Post a Comment