AppleScript Tutorial for Microsoft Excel
Easily generate barcodes in Excel for Mac with IDAutomation's AppleScript
files and Universal font. When data needs to be encoded in a barcode,
the script will format the data and return a character string that will
create an accurate barcode when combined with the appropriate Universal
Tutorial for Excel using Universal Fonts
This tutorial is designed to guide Mac users implementing AppleScript
within Excel for Mac 2004 and 2008. As a reference, two files included
in the Universal
Barcode Font Package, AppleScript_Excel_Example.xls
and the AppleScript_Excel_Example_IDAutomation128b.scpt
file can be used as a guide. Available in the licensed version only.
- Open the Excel Example or new Excel spreadsheet.
- In Column A, enter test data for rows A1, A2 and A3. In the
example, rows 1 through 3 of Column A already contain data.
- Save the Excel file.
- Open the AppleScript Editor and spreadsheet that will be used.
- Paste the code below into the AppleScript file. If the sample
script file is being used, the code has already been placed in the
script. Make sure that only one Excel worksheet is running.
NOTE: AppleScript_Excel_Example.xls is a working example using the
following code. When using a different spreadsheet, the code will
need to be modified to match the column and row set up.
--Run handler showing communication
tell sheet "Sheet1"
of workbook 1
3 -- This defines the last
Excel Row with data; it this example, it is A3.
-- This loop will run from
row 1 until EndofRow set above. For this example, it was set
value of (cell
("A1:A" & i))
-- This line defines the range,
where in this example it is set A1:A3 and i is the counter and
will continue to loop until EndofRow.
("B" & i)
-- This is where to designate
where the encoded data is to appear. In this example, the encoded
data will be in Column "B".
--End of Excel Code
- Save the changes, then compile and run the script. The Excel
spreadsheet now contains encoded data in cells B1 through B3 on
the example spreadsheet.
ensures that the encoded data is sent from the script directly to
Column B. To send the data to another column, simply enter
the Column letter.
- Change the font of the formula field to the IDAutomation Universal
Font and set the point size. This is a very important step; if this
is not done, barcodes will not be displayed. If unsure of the point
size, IDAutomation recommends 12 points.
- Print and scan the barcode(s) to verify the correct data is
encoded. If a scanner is needed to verify barcodes, IDAutomation