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

0 Members and 1 Guest are viewing this topic.

Offline JesterTopic starter

  • Frequent Contributor
  • **
  • Posts: 887
  • 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 »
 

Offline dmderev

  • Contributor
  • Posts: 35
Re: Excel - Visual Basic - 34401A Execute subroutine from a Function key
« Reply #1 on: October 06, 2024, 07:01:22 am »
Did you solve your problem? I am interested into the same - reading data when needed into Excel while measuring parts manually. Would like to use some USB trigger (a pedal from old mouse or keyboard).
Ideally after capture it should go on next row so that the results are collected as table. Anything you could share? Thanks!
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf