Author Topic: Excel - Visual Basic - 34401A Execute subroutine from a Function key  (Read 1275 times)

0 Members and 1 Guest are viewing this topic.

Offline JesterTopic starter

  • Frequent Contributor
  • **
  • Posts: 874
  • Country: ca
I have a working subroutine that gets the desired reading from a HP 34401A DMM and places it into the desired cell when I click on a button that I added to the spreadsheet.

However I'm probing the circuit while doing this, so I'm using my left hand to drive the mouse and get it pointing to the button, it would be much better if I could simply tap a key instead up click on the button.

I realize that you can assign a Ctrl-Key to initiate a subroutine, but again this is a PITA using a two-sequence key press when trying to simultaneously probe with my right hand.

Is there a way to have one of the function keys (F1-F12) initiate the subroutine?

I tried the following code (my subroutine is called "Measure_Click), however it does not work.

Private Sub Workbook_Activate()
    Application.OnKey "{F10}", "Measure_Click"
End Sub

If I can't use a function key, what about some other easy to operate external device for example I could connect a PB switch to a serial port and toggle RTS, I could even mount the PB to the probe handle that would be really slick.


Solved I needed to add the name of the worksheet...... this works

Private Sub Workbook_Activate()
    Application.OnKey "{F10}", "LPF.Measure_Click"
End Sub
« Last Edit: November 10, 2016, 02:00:27 pm by Jester »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf