shortcut key to call an Add in. In particular Find And Replace

------------- Question ---------------------

I want to be able to call certain addins quickly.
In particular, I often use Rick Frasier's Find and Replace.

Ctrl M F would be perfect.

How can I do that?  

------------- Back ground ---------------------


For future flexibility, I am writing a program that lets me choose from a bunch of functions

I'll use Autokeys to assign  ctrl M to runcode fncShortCutAsker()

public function fncShortCutAsker()
  s = inputbox "what to do?"
  select case lcase(trim(s))
  case "f"
        Msgbox "I don't yet know how to call Find and Replace"
  case else
        msgbox s & " is not a valid shortcut"

  end select
end function
LVL 5
rberkeConsultantAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Leigh PurvisDatabase DeveloperCommented:
Without knowing the details of how that AddIn is loaded (i.e. in code or whatever) you can create an AutoKeys macro with a key combination that will let you fire a function that calls the Method you require?
0
rberkeConsultantAuthor Commented:

The key question is "how to know the method".

For instance, In Excel and Word, I can turn on macro recorder,  the execute my desired function.

Access does not have such a function.

Perhaps someone knows how to dig into the menu system and pull a method from a menu name out of that?

In this particular case, I can email Rick Fisher, the author and ask.  But,
  #1)  I hate to bother Mr. Fisher for something so trivial
  #2)  in general, some addins might not give an email address


0
Leigh PurvisDatabase DeveloperCommented:
How do you currently execute it?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

rberkeConsultantAuthor Commented:
I executed it like I do all of my addins, from the access menu bar.  

Tools > Add Ins  > takes me to a list of the addin that I have installed. I then choose the one that says Find and Replace.
0
puppydogbuddyCommented:
rberke,
here is a comprehensive list of built in shortcut keys for Access.  I did not see a built-in shortcut for add-ins, so I guess the only solution would be to find a 3rd party macro recorder for access.

http://www.rnib.org.uk/xpedio/groups/public/documents/PublicWebsite/public_rnib003596.hcsp
0
Jeffrey CoachmanMIS LiasonCommented:
rberke,

As far as I know, key Combinations like Ctrl M F are not allowed in Access. (You can only have one letter)

Might I suggest Ctrl-Shift-M?

Create an AutoKeys Macro as LPurvis suggests.

(The name of this macro must be AUTOKEYS)

Open a New Macro
Save it as: AutoKeys
Click: View-->Macro Names
Macro Name:  ^+m
Action: SendKeys
KeyStrokes: "%{T}{I}{YourAddInHotkeyGoesHere}"
Wait: No

Here is the explanation
"^" is the Control Key
"+" is the Shit Key
"m" is the letter you want to press last to run the macro. Thus the macro runs when you press:
Control-Shift-m

The "Sendkeys" statement simulates keystrokes
"%" is the Alt
{X} is a keystroke
"Wait" Specifies whether the macro should pause until the keystrokes have been processed. Yes (to pause) or No (not to pause)

So...

If the hot key in your Add In menu for your Find and Relace Addin is "r", then your Sendkeys would look like this:
KeyStrokes: "%{T}{I}{R}"

Make sense?

It works, I tested it.

Now LPurvis, will probably dissaprove of my use of  Sendkeys. (And yes Sendkeys does have it's drawbacks)
;)
But...
<LP, yes I tried RunCode with an argument of a function that performed the Sendkeys, but I could not get it to work.....getting sleeeeeeepy>


Jeff


0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Leigh PurvisDatabase DeveloperCommented:
Well.... ;-)

If there's no obvious function call to invoke your addin then so be it.
You might want to consider the slightly safer API wrapped version
http://www.mvps.org/access/api/api0046.htm

0
rberkeConsultantAuthor Commented:
It works!    My autokeys  uses ^m  runcode fncShortCutAsker()  

My vba then calls SendKeys as follows

  public function fncShortCutAsker()
  s = inputbox "what to do?"
 
  select case lcase(trim(s))
  case "f"
        sleep (5000)   ' see note below
        SendKeys "%{T}{I}{a}"
  case else
        msgbox s & " is not a valid shortcut"
  end select
  end function

But, exactly how dangerous is this?  

For instance LPurvis's link says
  SendKeys is not recommended in a production environment.  This is because the keystrokes are processed by whichever window is currently active on the desktop.  Obviously this will cause unpredictable behavior
  in case another app receives the focus while your code is processing

I tried to simulate another app receiving focus by putting in a sleep (5000) . I switched to Word, but the keystrokes never seemed to go into Word they just disappeared

Naturally, I removed the sleep function.  

My guess is that it is a pretty safe solution to my problem, especially since users will never use it, only me.

0
Leigh PurvisDatabase DeveloperCommented:
Sendkeys processes regardless of what the current window (and hence even application) is.
So all things being equal - it looks flawless.
And if you're the only one using it then what's the harm (but keep an eye on your Numlock - Sendkeys is buggy - that's one of the reasons for the trepidation - hence the point of the link's code)

However (just as an example here) if you were on a dog of a machine (users - hard to predict the crap they'll have installed) then if the window changed before the code completed then the sendkeys would try to fire on whatever active window it found.

If it works for you and you're happy with it then go for it.
(I'd still have like to find the library and function to perhaps call directly - but I don't currently have any add-ins installed to try it for you).
0
Jeffrey CoachmanMIS LiasonCommented:
rberke,
Glad I could help.
My guess from your post is that you had a pretty good idea about what you wanted.
I posted my solution as just an alternative so you could just "Get it done".
I had noticed that the Q was open for about a month.

You might want to drop the Rick Fisher a line and ask him if (As LPurvis states) there is a way it invoke the add-in via code.


LPurvis,
I even tried to simulate navigating the menu commands via VBA, but no luck.
Yes, I rarely use send keys because of the way it works around dialog boxes.
I have NEVER used it to simulate more than 3 keystrokes.
I use it mainly temporarily to "Make" something happen if I am testing some code.

Interestingly enough, I ued to use Sendkeys all the time, when I would set focus to a text box and simulate pressing the F2 function key to put the user in "Edit" mode.
    SendKeys "{F2}"

That is, until YOU taught me to use SelStart!:
    txtSearch.SelStart = Nz(Len(txtSearch))
:)
0
Leigh PurvisDatabase DeveloperCommented:
:-D
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.