Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 281
  • Last Modified:

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
0
rberke
Asked:
rberke
  • 5
  • 3
  • 2
  • +1
3 Solutions
 
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
 
rberkeAuthor 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
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
rberkeAuthor 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
 
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
 
rberkeAuthor 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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 5
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now