Automating Metrics: creating your first macro

We have talked about the format, now how do get the commands?

Two ways of getting the commands to put into a macro,

1. Copy and paste from the history menu. It can be found with an icon on the tool bar that is yellow with a > in it.

2. From any completed chart/graphic. With the chart open, you go to the editor menu a the top “Editor>Copy Command Language”. This function is not available with a right click.

The graphical summary is one graphic that can only be generated with the menu commands, the copy command language will not work.

Another nice thing to know is that any line in the macro file that has a first character as a (#) will be interpreted as a comment. You can use this to write notes to yourself and identify where different actions are taken in the macro.

Now for an example:

We will create a random normal data set with 25 numbers, make a histogram and an I chart.

If you try it yourself, start with a blank minitab project (just opened minitab) in order to duplicate my information

Make normal data
Calc>Random Data>Normal
25 rows, with a column name of data.
Leave a mean of 0 and standard deviation of 1

Graph>Histogram Simple
data variable is data

Stat>control charts>variables charts for individuals>individual…
varriable is Data

Look into the History Window and you should see the following

Name c1 “data”
Random 25 ‘data’;
Normal 0.0 1.0.
Histogram ‘data’;
YFrequency;
Bar.
IChart ‘data’.

Now lets create a macro and run it.

Open Notepad (or other text editor)
On the first two lines type;
gmacro
testmacro.

Now copy and paste the 7 lines from the history window in minitab (shown above)

now type
endmacro.
on a new line at the end, (note there is a period after endmacro and testmacro.)

Now perform a “save as” and save the text file to the Minitab Macro Directory. Use the name of
myfirstmacro.mac
Now you have to change the file type from .txt to all or it will append the .txt on the end of your file.

For V15 the default macro directory is found at;
C:\Program Files\Minitab 15\English\Macros\

To run the macro. Open a new minitab project that is blank.
Edit>Command Line Editor (or CTRL-L)

type in
%myfirstmacro
and then press the submit commands button and it will run.

Comments are closed.