Assign "RunMacro" to an action cell?

M

Michael Pollard

I am trying to assign a RunMacro formula to an action cell, but it seems to
try to evaluate the RunMacro rather than assigning the string.

The formula works for a "EventDblClick", but not for
"Actions.<action>.Action", because it has to be slightly different
syntactically. The Action wants no surrounding quotation marks and only
single embedded quotes, which is different than a regular formula such as the
Event accepts.

But the formula the Action wants seems to be blocked by VBA, as it seems to
want to evaluate it rather than just copy it.

Specifically:
Code: MyObject.CellsU("EventDblClick").Formula =
StringToFormula("RunMacro(""MacroName"")")
Results, in the cell: ="RunMacro(""MyMacro"")"
This works.

Code: MyObject.CellsU("Actions.<action>.Action").FormulaU =
StringToFormula("RunMacro(""MyMacro"")")
Results: ="RunMacro(""MyMacro"")"
The results are the same as before, but this doesn't work. When I select the
action, nothing happens.

If I manually edit the cell to: =RunMacro("MyMacro")
this works.

So I try to programatically insert it.
Code: CurrentObject.CellsU("Actions.Select.Action").Formula =
StringToFormula("RunMacro("MyMacro")")
but this gives: "Compile error: Expected: list separator or )"

Any ideas? (RunMacro has very limited documentation...)
 
J

JuneTheSecond

you have only to write like
shp.Cells("Actions.Row_1.Action").Formula = "RUNMACRO(""MyMacro"")"
 
M

Michael Pollard

Well, what do you know? The .Formula actually works (almost) logically with
this one! (Maybe the others pass their contents elsewhere as a parameter,
thus requiring the double-formatting done by the ToFormula function MS has in
their code library...)

My code runs much more quickly now, without all the function string
processing.

Thank you very much.
 

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