Page 1 of 1

[Solved] Macro within a macro in AOO Calc. Is it possible?

PostPosted: Fri Sep 22, 2017 8:18 pm
by iadummy
I'm trying to make a macro in open office calc that basically does this:

1. Moves to cell A1.
2. Clicks a button in A1 that runs another macro.
3. Copies the result of that macro.
4. Pastes the result into cell A2.

The problem is the macro in step that I'm trying to run doesn't run (but it does run good by itself, when not inside this macro I'm trying to make).

Can this even be done? If so, is there a fairly easy way to get it done (iadummy, not an advanced spreadsheet whiz :)? Got any advice? TIA for all help!

Re: Macro within a macro in open office calc. Is it possible

PostPosted: Fri Sep 22, 2017 10:16 pm
Steps 1 and 2 are not necessary. One macro subroutine can simply call another. It sounds like the macro associated with the button is a function, it returns a value. The structure of your code would then be
Code: Select all   Expand viewCollapse view
function MyFunc(Var)
  MyFunc = SomeValue
End Function

Sub MyProcedure
  p = ResultOfSomeCode
  x = MyFunc(p)
  ...Write x to cell A2...
End Sub

SOLVED! Re: Macro within a macro in AOO Calc. Is it possible

PostPosted: Mon Sep 25, 2017 3:17 am
by iadummy
I have to call this "solved" for possibly 2 reasons.

The for sure reason is, after I sent this message I found that if I clicked the button to start the macro, then went behind the macro and changed the number in the cell, I could get the entire macro to work. (Clicking the macro changed the number behind the button to "1", which triggers the macro. So instead of continuing to press the button, I continued to change the number to "1" and it works the way I want.

The second possible reason is the answer you gave me, which I didn't check to see if it works. But if it does, well, that's 2 ways to do it.

Thanks for the help! :D