Jump to content
Macro Express Forums

"Set Value from List" - New in 6.1.1.1


Recommended Posts

I'm finding a new feature in the latest version of Macro Express 6 very interesting.  (The command is so new that it doesn't have a Help page.)

 

I am experimenting with "Set Value from List" in a script to give quick access to commands that I use regularly (for testing purposes, in Word and PowerPoint). Because the commands are buried deep in complex menus and ribbons, my two motivations for developing the command were to spend less mental and physical energy trying to find commands, and to avoid memorizing more hotkeys.

 

Now, I press one key (F1) to access the list, type one or two characters (which selects an item on the list) and then press Enter to activate the command. The characters are related logically to the command I want. For example, to use bullet points:

 

F1 then b

 

To change the paragraph spacing:

 

F1 then p

 

To set font colours:

 

F1 then c

or

F1 then co

 

To turn on the crop tool:

 

F1 then cr

 

The script gives functionality similar to old-style "dead key" commands, but it's a menu, so one can get visual feedback about the choices.

 

I spent a couple of hours developing the command earlier this week, but I've already gained back most of that time. And the script is more fun than to click click click hunting for commands. 

 

I would be curious about the uses others have found for the "set value from list" instruction.

Link to comment
Share on other sites

Hi @cantor,

 

Briefly tried it (handicapped by lack of help page with an example from Insight) but can't really see its advantage over my familiar menu method using menus.

 

Most of my macros are accessed while working in a specific application. For those most frequently used I probably have a well-remembered KB shortcut or localised mouse click. For others (over a thousand) I use menus like the attached example.

 

And most of my macro names begin with a verb (Copy, Move, Get, etc) so two or three keystrokes would be inadequate.

 

--------------------

Can you please expand a little on how your macro proceeds to run the target macro after getting its full name into the variable via a prompt?

 

Terry, East Grinstead, UK

 

 

Menu-Example.jpg

Link to comment
Share on other sites

Good point, Terry, about using MEP menus. At this point, my script does not trigger other macros. Everything is done in one script. Perhaps it's a refinement I could add. Right now, my script for Word provides shortcuts for AutoCorrect, Crop, Centre-centre align a table cell, centre-left align a table cell, customize, numbering, sort, sum, thesaurus, wrap text, and "Test" (which copies a sentence in Word, pastes it in Excel, and switches back to Word.)

 

I'm experimenting with different methods for activating these commands. The most common method is to send the sequence of keystrokes to tunnel through the ribbons. Very important: The keys sequences change from version to version of Word, so you may need to adjust the script!!)

 

For example, to activate the Customize menu:

 

<ALT>f

ic

<ALT>t

 

For reasons I don't understand, a slightly different method is needed for commands in the "Picture Tools" ribbon.

 

I've also experimented by calling up Word commands directly via Word's macro run command, which by default is assigned to Alt + F8. This is probably the most reliable method, but it's not easy to figure out the real name of Word commands!

 

My drop down list consists of these items::

 

a       AutoCorrect
auto    AutoCorrect
c       Crop
cc      Centre-centre align a table cell
cl      Centre-left align a table cell
cu      Customize
n       Numbering
s       Sort
sum     Sum
t       Thesaurus   
w       Wrap text
x       Test

There are spaces between the two columns.

 

When a list item is selected, the script copies the line from the first character to the character before the first space. For example, "a" for AutoCorrect or "auto" for AutoCorrect.

 

The script "remembers" the last command used, so it's easy to access a command over and over. For example, if I want to use "Sort" repeatedly, I press "F1, s, Enter" the first time, and then "F1, Enter" subsequently.

 

// This script, triggered by F1, simulates the Alt+Q feature bulit into recent versions of Word
 
// It allows easy access to commands I frequently use, commands that are by default buried deep in ribbons and menus, or are hard to find
// But instead of drilling through the user interface, I can access the commands by typing an easy-to-remember code or abbreviation.
 
// The script "remembers" the previous command. So just press "F1 Enter" to repeat the most recently chosen command.
 
:Start
Variable Restore: Restore Text Variables
 
Variable Set String %x%: from List
Variable Set String %y% to "%x%" // Copy x to y, and then parse y. We retain value of x for the next time the macro is triggered
 
Variable Set Integer %SpacePosition% to the position of " " in %y%
 
If Variable %SpacePosition% Is Greater Than "0"
  Variable Modify Integer: %SpacePosition% = %SpacePosition% - 1
  Variable Modify String: Copy part of text in %y% starting at 1 and %SpacePosition% characters long to %y%
End If
 
Switch( %y% )
Case: a // AutoCorrect
  Text Type (Simulate Keystrokes): <ALT><F8> // Run a Word  macro
  Text Type (Simulate Keystrokes): toolsautocorrect<ENTER> // This is the name of the built-in Word command
End Case
 
Case: c // Crop
  Delay: 200 milliseconds // Not sure why a delay is needed here!
  Text Type (Simulate Keystrokes): <ALTD><ALTU>jp // Not sure why Alt down and up are needed!
  Text Type (Simulate Keystrokes): c
End Case
 
Case: cc // Centre-centre align a table cell
  Text Type (Simulate Keystrokes): <ALT>jlcc
End Case
 
Case: cl // Centre-left align a table cell
  Text Type (Simulate Keystrokes): <ALT>jlcl
End Case
 
Case: cu // Customize
  Text Type (Simulate Keystrokes): <ALT>fic<ALT>t
End Case
 
Case: n // Numbering
  Text Type (Simulate Keystrokes): <ALT>hn<HOME><ARROW RIGHT><ENTER>
End Case
 
Case: s // Sort
  Text Type (Simulate Keystrokes): <ALT>hso
End Case
 
Case: sum // Sum
  Text Type (Simulate Keystrokes): <ALT>jlul<ENTER>
End Case
 
Case: t // Thesaurus
  Text Type (Simulate Keystrokes): <ALT><F8>toolsthesaurus<ENTER>
End Case
 
Case: w // Wrap text
  Delay: 200 milliseconds // Not sure why a delay is needed here!
  Text Type (Simulate Keystrokes): <ALTD><ALTU>jp // Not sure why Alt down and up are needed!
  Text Type (Simulate Keystrokes): tw
End Case
 
Case: x // Test - copy a sentence in Word, paste it into Excel, return to Word, deselect
  Text Type (Simulate Keystrokes): <ESC>
  Text Type (Simulate Keystrokes): <F8><F8><F8>
  Clipboard Copy
  Window Activate: Microsoft Excel - 
  Delay: 200 milliseconds
  Clipboard Paste
  Text Type (Simulate Keystrokes): <ARROW DOWN>
  Delay: 500 milliseconds
  Window Activate: - Microsoft Word
  Delay: 200 milliseconds
  Text Type (Simulate Keystrokes): <ARROW RIGHT>
End Case
 
Default Case
  Text Box Display: 
  Goto:Start
End Case
End Switch
 
Variable Save: Save Text Variables
<COMMENT Value="This script, triggered by F1, simulates the Alt+Q feature bulit into recent versions of Word"/>
<COMMENT/>
<COMMENT Value="It allows easy access to commands I frequently use, commands that are by default buried deep in ribbons and menus, or are hard to find"/>
<COMMENT Value="But instead of drilling through the user interface, I can access the commands by typing an easy-to-remember code or abbreviation."/>
<COMMENT/>
<COMMENT Value="The script \"remembers\" the previous command. So just press "F1 Enter" to repeat the most recently chosen command."/>
<COMMENT/>
<LABEL Name="Start"/>
<VARIABLE RESTORE Option="\x01"/>
<COMMENT/>
<VARIABLE SET STRING Option="\x0C" Destination="%x%" Caption="Code for command" Prompt="Prompt" Choices="a         AutoCorrect\r\nauto    AutoCorrect\r\nc          Crop\r\ncc        Centre-centre align a table cell\r\ncl         Centre-left align a table cell\r\ncu        Customize \r\nn          Numbering\r\ns          Sort\r\nsum     Sum\r\nt          Thesaurus   \r\nw         Wrap text" DefChoice="1" Style="FALSE" OnTop="TRUE" Left="Left" Top="Top" Monitor="0" NoEmbeddedVars="FALSE"/>
<VARIABLE SET STRING Option="\x00" Destination="%y%" Value="%x%" NoEmbeddedVars="FALSE" _COMMENT="Copy x to y, and then parse y. We retain value of x for the next time the macro is triggered"/>
<COMMENT/>
<VARIABLE SET INTEGER Option="\x0E" Destination="%SpacePosition%" Text_Variable="%y%" Text=" " Ignore_Case="FALSE"/>
<COMMENT/>
<IF VARIABLE Variable="%SpacePosition%" Condition="\x03" Value="0" IgnoreCase="FALSE"/>
<VARIABLE MODIFY INTEGER Option="\x01" Destination="%SpacePosition%" Value1="%SpacePosition%" Value2="1"/>
<VARIABLE MODIFY STRING Option="\x09" Destination="%y%" Variable="%y%" Start="1" Count="%SpacePosition%" NoEmbeddedVars="FALSE"/>
<END IF/>
<COMMENT/>
<SWITCH Variable="%y%"/>
<CASE Value="a" _COMMENT="AutoCorrect"/>
<TEXT TYPE Action="0" Text="<ALT><F8>" _COMMENT="Run a Word  macro"/>
<TEXT TYPE Action="0" Text="toolsautocorrect<ENTER>" _COMMENT="This is the name of the built-in Word command"/>
<END CASE/>
<COMMENT/>
<CASE Value="c" _COMMENT="Crop"/>
<DELAY Flags="\x02" Time="200" _COMMENT="Not sure why a delay is needed here!"/>
<TEXT TYPE Action="0" Text="<ALTD><ALTU>jp" _COMMENT="Not sure why Alt down and up are needed!"/>
<TEXT TYPE Action="0" Text="c"/>
<END CASE/>
<COMMENT/>
<CASE Value="cc" _COMMENT="Centre-centre align a table cell"/>
<TEXT TYPE Action="0" Text="<ALT>jlcc"/>
<END CASE/>
<COMMENT/>
<CASE Value="cl" _COMMENT="Centre-left align a table cell"/>
<TEXT TYPE Action="0" Text="<ALT>jlcl"/>
<END CASE/>
<COMMENT/>
<CASE Value="cu" _COMMENT="Customize"/>
<TEXT TYPE Action="0" Text="<ALT>fic<ALT>t"/>
<END CASE/>
<COMMENT/>
<CASE Value="n" _COMMENT="Numbering"/>
<TEXT TYPE Action="0" Text="<ALT>hn<HOME><ARROW RIGHT><ENTER>"/>
<END CASE/>
<COMMENT/>
<CASE Value="s" _COMMENT="Sort"/>
<TEXT TYPE Action="0" Text="<ALT>hso"/>
<END CASE/>
<COMMENT/>
<CASE Value="sum" _COMMENT="Sum"/>
<TEXT TYPE Action="0" Text="<ALT>jlul<ENTER>"/>
<END CASE/>
<COMMENT/>
<CASE Value="t" _COMMENT="Thesaurus"/>
<TEXT TYPE Action="0" Text="<ALT><F8>toolsthesaurus<ENTER>"/>
<END CASE/>
<COMMENT/>
<CASE Value="w" _COMMENT="Wrap text"/>
<DELAY Flags="\x02" Time="200" _COMMENT="Not sure why a delay is needed here!"/>
<TEXT TYPE Action="0" Text="<ALTD><ALTU>jp" _COMMENT="Not sure why Alt down and up are needed!"/>
<TEXT TYPE Action="0" Text="tw"/>
<END CASE/>
<COMMENT/>
<CASE Value="x" _COMMENT="Test - copy a sentence in Word, paste it into Excel, return to Word, deselect"/>
<TEXT TYPE Action="0" Text="<ESC>"/>
<TEXT TYPE Action="0" Text="<F8><F8><F8>"/>
<CLIPBOARD COPY/>
<WINDOW ACTIVATE Title="Microsoft Excel - " Exact_Match="FALSE" Wildcards="FALSE" _IGNORE="0x0006"/>
<DELAY Flags="\x02" Time="200"/>
<CLIPBOARD PASTE/>
<TEXT TYPE Action="0" Text="<ARROW DOWN>"/>
<DELAY Flags="\x02" Time="500"/>
<WINDOW ACTIVATE Title="- Microsoft Word" Exact_Match="FALSE" Wildcards="FALSE" _IGNORE="0x0006"/>
<DELAY Flags="\x02" Time="200"/>
<TEXT TYPE Action="0" Text="<ARROW RIGHT>"/>
<END CASE/>
<COMMENT/>
<DEFAULT CASE/>
<TEXT BOX DISPLAY Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs40 \"%x%\" not defined\\f1 \r\n\\par }\r\n" Left="701" Top="409" Width="349" Height="145" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>
<GOTO Name="Start"/>
<END CASE/>
<END SWITCH/>
<COMMENT/>
<VARIABLE SAVE Option="\x01"/>

 

Link to comment
Share on other sites

Thanks Alan, appreciate that thorough explanation.

 

I'll probably experiment further but I'm now committed so heavily to my menu-based workflow that I suspect I won't use that new command much. All menus like that example I gave are displayed by a mouse middle click in the application's title, so access is quite fast.

 

I don't work in Word a lot but for Excel I too have quite a few MEP macros that run VBA macros - a powerful combination. This example runs my Excel VBA macro called 'SelectLastInCol_A'

 

Text Type (Simulate Keystrokes): <ALT><F8>
Delay: 0.1 seconds
Text Type (Use Clipboard and Paste Text): PERSONAL.xlsb!SelectLastInCol_A
Delay: 0.1 seconds
Text Type (Simulate Keystrokes): <ENTER>
Delay: 0.2 seconds

 

<TEXT TYPE Action="0" Text="<ALT><F8>"/>
<DELAY Flags="\x01" Time="0.1"/>
<TEXT TYPE Action="1" Text="PERSONAL.xlsb!SelectLastInCol_A"/>
<DELAY Flags="\x01" Time="0.1"/>
<TEXT TYPE Action="0" Text="<ENTER>"/>
<DELAY Flags="\x01" Time="0.2"/>

 

Further explanatory images attached, although I expect you're more confident with this stuff than I am. Almost all my VBA macros have been written in copy/paste mode, sourced by several Excel forums then tailored, largely by trial and error. But the appeal of this approach is that all the MEP macros follow the same format as above, with all the functionality in the Excel/Word macro. With that being either written (or pasted) in the VBA Editor (Alt+F11 to access quickly), or recorded and edited.

 

--------------------

 

BTW, why doesn't your initial access hotkey of F1 bring up Word's Help, as it does here?

 

Terry, East Grinstead, UK

 

 

 

 

 

ExcelExampleForAlan.jpg

ExcelExampleForAlan-2.jpg

Link to comment
Share on other sites

Hi Terry,

 

Text Type (Simulate Keystrokes): <ALT><F8>
Delay: 0.1 seconds
Text Type (Use Clipboard and Paste Text): PERSONAL.xlsb!SelectLastInCol_A

I learned today that VBA can be "translated " into VBScript, which means it may be possible to use MEP's External script functionality to activate Microsoft Office VBA scripts directly from Macro Express.  The advantage of programmatic activation is that MEP scripts would be more reliable, execute faster, and would not use the clipboard.  

 

Quote

BTW, why doesn't your initial access hotkey of F1 bring up Word's Help, as it does here?

 

 

If you create a MEP script and assign it to F1, Macro Express "sees" it before Word does, so in effect, you are using MEP to reassign the Word hotkey.

Link to comment
Share on other sites

Quote

(The command is so new that it doesn't have a Help page.)

 

It turns out it does have a Help page. Open the screen for "Set Value from List," press F1, scroll to the end of the page, and voilà!

 

(If you want to try my test macro, above, which uses F1 to display the list, you will want to set the scope to window or program specific so that F1 continues to work in other programs.)

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