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

Creating a macro - Writing a Script - Using the API

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

Postby iadummy » Fri Sep 22, 2017 8:18 pm

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!
Last edited by Hagar Delest on Mon Sep 25, 2017 1:00 pm, edited 1 time in total.
Reason: tagged [Solved].
Open Office 4.1.2 on Windows 7
iadummy
 
Posts: 2
Joined: Fri Sep 22, 2017 7:52 pm

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

Postby FJCC » 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)
  ...code...
  MyFunc = SomeValue
End Function

Sub MyProcedure
  p = ResultOfSomeCode
  x = MyFunc(p)
  ...Write x to cell A2...
End Sub
Windows 10 and Linux Mint, since 2017
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
FJCC
Moderator
 
Posts: 7160
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

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

Postby iadummy » Mon Sep 25, 2017 3:17 am

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
Open Office 4.1.2 on Windows 7
iadummy
 
Posts: 2
Joined: Fri Sep 22, 2017 7:52 pm


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 8 guests