Using a QR code to launch a macro

rickblunt

Well-known Member
Joined
Feb 18, 2008
Messages
609
Office Version
  1. 2019
Platform
  1. Windows
Hello, does anyone know if its possible to trigger a macro with a QR code? I use a mess of userforms along with QR codes to quickly enter in data and such during our inspections. The userforms have commandbuttons on them to do additional functions that I click on manually. With one of my QR codes I have added a carriage return to click on the default button, but it occurred to me that it would be cool if I could use a QR code to trigger the other button(s).

Since all the QR does is enter a string of text/symbols, I guess the question would be how to trigger a macro by using text - anyone have any ideas? I appreciate any thoughts, no matter how crazy :) thanks
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
If you have the scanner to trigger carriage return, then you can use worksheet change event to run macro. The sheet can be hidden sheet if the changed value is not used anywhere.
 
Upvote 0
I don't know if it is possible but maybe you can assign accelerators to Command Buttons etc, or key shortcuts to specific macros listed on the "Run Macro" list (ALT + F8). What I am not sure here is whether you can send modifier (CTRL/SHIFT/ALT) & key combos.

Another method that comes to mind is sending TAB/ SHIFT + TAB, so you can move between controls, and use your Carriage Return QR code.
 
Upvote 0
I appreciate the response.

Yes, I can cycle through the comandbuttons by using tab and other QR symbols. But I was wondering if I could have a single userform with a textbox and a commandbutton on it. Then scanning the QR code would pass the name of the sub into the textbox and then trigger the sub to run. I have never "triggered" a sub to run by calling out its name per se, usually you use a button or time event or something like that to initiate the sub.

I guess it would or could be like using a keyboard shortcut to trigger the macro, there is a "control" character in a QR code, maybe that is a possibility.....
 
Upvote 0
Yes, you can definitely have a textbox that can call other subs, can even have arguments depending on what you enter to it. No need for a command button even. You would have to return the focus to the userform and textbox afterwards though. I guess a modeless userform would be needed.
 
Upvote 0
Solution
oh, of course (sound of face palm here) just "call" the contents of textbox1 as it were. Thanks for pointing my brain in the right direction :)
 
Upvote 0
If you have the scanner to trigger carriage return, then you can use worksheet change event to run macro. The sheet can be hidden sheet if the changed value is not used anywhere.
Ahh - that's is a good thought as well. I almost always have a hidden "coding" sheet in my WB's just for that type of function. thanks for the idea ;)
 
Upvote 0
Just to give an idea how you can call macros, below is a screenshot of my app.

In order to invoke any action, one can:

- Enter an action (string) in the Action range (sheet change event that calls a macro)
- Enter an action using the textbox on the userform (calls the macro directly)
- Click the labels on the userform (for preset configurable actions) using combinations of: Single/double click of Left/right/middle mouse buttons and Modifier keys (Ctrl/Alt/Shift/None). The duration of the clicks themselves also change the behavior (which I call Single/Short/Long/Hold clicks). That's more than 50 combinations on a single label. (calls the macro directly)
- Using Speech Recognition utilizing a custom grammar rule. (calls the macro directly)


LazyD Charter.jpg
 
Upvote 0
ok, the first two I should be able to figure out - Speech recognition? Now you are making my head explode! lol I have learned a lot from all of you on this website, but you all still amaze me at the possibilities of what you are able to do. Wow.
 
Upvote 0
It is pretty simple once you get to know it. Maybe I should write an article about it :) The info is out there but not in a single place unfortunately. I have 50 pages bookmarked about it, and some more I didn't bother bookmarking.
 
Upvote 0

Forum statistics

Threads
1,214,593
Messages
6,120,434
Members
448,961
Latest member
nzskater

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top