Problems with Macros

N

neoz

Version: 2008
Operating System: Mac OS X 10.5 (Leopard)
Processor: Intel

I am attempting to migrate functionality from VBA to Applescript. I have created my first Applescript macro and can run it from ScriptEditor. I can also make it show up in the AppleScript menu when I am running in Excel. It all works fine.

What I want is to assign this macro to a button. I have inserted a shape. When I right click on the shape I can select "Assign Macro..." which brings up a dialog showing no Macros.

The question then is: how do I assign the macro I have created in AppleScript to this object?

Second, but related question with possibly the same answer. Is what is the Tools-Macro dialog for? Again it never shows any Macros. The only button that ever seems to be active is the Cancel button.

Thanks
 
B

Bob Greenblatt

Version: 2008
Operating System: Mac OS X 10.5 (Leopard)
Processor: Intel

I am attempting to migrate functionality from VBA to Applescript. I have
created my first Applescript macro and can run it from ScriptEditor. I can
also make it show up in the AppleScript menu when I am running in Excel. It
all works fine.

What I want is to assign this macro to a button. I have inserted a shape. When
I right click on the shape I can select "Assign Macro..." which brings up a
dialog showing no Macros.

The question then is: how do I assign the macro I have created in AppleScript
to this object?

Second, but related question with possibly the same answer. Is what is the
Tools-Macro dialog for? Again it never shows any Macros. The only button that
ever seems to be active is the Cancel button.

Thanks
Both of your questions are answered in this response. First, you can NOT
assign an apple script to a worksheet button. What you need to do is create
an XLM macro that calls your Apple script. Press Command-F11 to insert a
macro sheet. In a convenient cell enter the formula:
=exec(disk:folder:compiled script)

Use insert Name- Define to assign a name to the macro. Click on command.
Then in the cell immediately below the Exec command, enter:
=return()

Now, return to your worksheet, right click on the button, and you can now
assign the macro you just built to the button.
 
N

neoz

Thanks Bob. The information is really helpful. Everything you said worked great down to it recognizing my script. I can't seem to get it to recognize the location of my script and being an XLM virgin I'm a bit stuck. I have:

=EXEC(Macintosh HD:Users:Neoz:Desktop:Scripts:My New Script.scpt)

When I Step Into this and evaluate it it just says

=EXEC(#NAME?)

The script never runs.

Thanks for the help
 
N

neoz

Thank Bob.

I had tried that initially with both single and double quotes, but I'm not getting much love.

When I put the path name in single quotes and press enter in the cell (i.e.
=EXEC('Macintosh HD:Users:Neoz:Desktop:Scripts:My New Script.scpt') )

I get a dialog saying: "The formula you typed contains an error....'

If I use double quotes it accepts the contents of the cell without error, but when I click my button to run the script I get a dialog saying "Macro Error at cell:[My New Script.xlsm]Macro1!A1
 
B

Bob Greenblatt

Thank Bob.

I had tried that initially with both single and double quotes, but I'm not
getting much love.

When I put the path name in single quotes and press enter in the cell (i.e.
=EXEC('Macintosh HD:Users:Neoz:Desktop:Scripts:My New Script.scpt') )

I get a dialog saying: "The formula you typed contains an error....'

If I use double quotes it accepts the contents of the cell without error, but
when I click my button to run the script I get a dialog saying "Macro Error at
cell:[My New Script.xlsm]Macro1!A1
Use double quotes. Is your script compiled? Is it at the location specified?
Does it run without error alone?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top