Microsoft KB Archive/188664

= XL98: How to Pass a Cell Value to an AppleScript Variable =

Article ID: 188664

Article Last Modified on 6/17/2005

-

APPLIES TO


 * Microsoft Excel 98 for Macintosh

-



This article was previously published under Q188664



SUMMARY
This article includes a sample AppleScript script that demonstrates how to set a variable in your script to a value in a Microsoft Excel worksheet cell.



MORE INFORMATION
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. AppleScript is manufactured by Apple Computer Inc., a vendor independent of Microsoft; we make no warranty, implied or otherwise, regarding this product's performance or reliability.

The following steps demonstrate how to set an AppleScript variable to value stored in an Excel worksheet:  Start the Script Editor from the HD:Apple Extras:AppleScript folder.  Type the following into the script window (lower pane): tell application "Microsoft Excel"

-- Activates Microsoft Excel. Activate

-- Assigns the value of cell A1 to the variable myvar. copy Value of Cell "A1" to myvar

-- Displays a dialog box with the value of myvar. display dialog myvar

-- Assigns the value of myvar to cell B1. set Value of Cell "B1" to myvar & " test"

end tell  On the File menu, click Save. Type a name for your script and click Save. Start Microsoft Excel. Enter any text into cell A1 of Sheet1. Leave Excel running and click Script Editor on the Application menu (in the upper-right corner of the screen).</li> Run your script.

A dialog box will display the value you typed into cell A1.</li> Click OK.

The value you typed into cell A1 will now appear in cell B1 with "test" appended to it.</li></ol>

<div class="references_section">