Jump to content
Macro Express Forums

Do you have a good use for "Variable Set String from List"?


Recommended Posts

A few years ago, Insight added "Set Value from List" to the "Variable Set String" instruction:

 

List.thumb.jpg.370058b9ad8f937e15be4c9dbac2087b.jpg

 

Variable Set String %Item%: from List

 

So far, I've found one practical use of this: to quickly invoke the commands I use most often in Word and PowerPoint. For me, this is a better option than the alternatives: click-click-click through endless menus and ribbons; press unwieldy sequences of keys to navigate through menus and ribbons; or memorize hotkeys. (And not every action I perform is assigned a hotkey.)


I made two versions of the same macro, one for Word, the other for PowerPoint. Each script makes it easy to choose one of about 20 commands by pressing as few as two keystrokes.

 

(Another alternative would be to use Macro Express to create hotkeys for each action. But with 20 * 2 = 40 commands, that's a lot to memorize.)

 

Is anyone else using Set Value from List? And if so, how are you using it?

Link to comment
Share on other sites

4 hours ago, Samrae said:

I use it to display a list of companies. When I select one the macro opens the correct website and gets ready to type login credentials.

 

Good idea!

 

When the list appears, do you use the mouse or the keyboard to select a company name? Or a combo?

Link to comment
Share on other sites

There's another way to navigate directly to the desired list item:

 

The list supports incremental searches. These searches always start from the leftmost character on each line of the list. For example, if this is the list:

 

Almond

Apple

Apricot

Avocado

 

You can reach "avocado" by typing its first two letters: "av". This is less work than pressing "a", then Down three times.

 

Similarly, you can reach "apricot" by typing "apr". This works because the third letter is what distinguishes "apricot" from "apple".

 

A good naming convention makes choosing a list item efficient and intuitive. A list like the following will never require more than two key presses to choose any item, even if the list contains hundreds or thousands of items:

 

aa

ab

ac

ad

...

az

ba

bb

...

zy

zz

 

I have a Macro Express script to automate tasks in Word. The start of the list looks something like this:

 

a  AutoCorrect

b  Bullets

c  Crop

cc Center-center align

cl  Center-left align

co Columns

cu Customize

...

 

Therefore, commands are activated by pressing sequences of either only three or four keys:

 

1. The hotkey to start the macro

2. The first one (or two) letters of the list item I want.

3. Enter.

 

Incremental searches rock! :)

Link to comment
Share on other sites

Thank you acantor! Until now I did not know that incremental searches work in that list.

 

Upon further experimentation it turns out that if you type quickly enough it works. But, if you type too slowly it may not. For example, if I type "ve" it brings up "Venmo" but if I type "v" ... "e" it brings up Enphase.

 

Now that I know I'll try to get these old fingers to type quicker. 😉

Link to comment
Share on other sites

A good naming convention goes a long way toward reducing the need to type quickly, or to type multiple characters. I try to use unique, single characters at the start of each list item:

 

1  Single-spaced

2  Double-spaced

a  Auto-correct

b  Bullets

c  Crop

...

k  Columns

 

(Notice I used K for columns to avoid a conflict with C for crop.)

 

My macro locates the location of the first space in the string, copies the string to a variable, and then uses the value to decide what to do...

 

Variable Set String %x%: from List

Variable Set Integer %SpacePosition% to the position of " " in %x%
Variable Modify Integer: %SpacePosition% = %SpacePosition% - 1

Variable Modify String: Copy part of text in %x% starting at 1 and %SpacePosition% characters long to %y%
 
Switch( %y% )
Case: a // AutoCorrect
// [Do something]
End Case
 
Case: b // Bullets
// [Do something]
End Case
 
Case: c // Crop
// [Do something]
End Case

etc.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...