[Solved] Writing a Macro

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
ptownpapa
Posts: 24
Joined: Mon Oct 09, 2017 2:58 am

[Solved] Writing a Macro

Post by ptownpapa »

I assumed, ha ha, that when it said "record macro" I simply entered the commands etc and "stopped recording" and saved it.
When I said "run macro" to my surprise it went through the motions - going from cell to cell - but no data was moved or modified.
I read the instructions, noted the admonition about keyboard not mouse, tried that still no go.
What have I missed?? Please help.
Last edited by ptownpapa on Thu Jul 05, 2018 9:10 pm, edited 1 time in total.
openoffice 4.1.3 on Wndows 10
UnklDonald418
Volunteer
Posts: 1549
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Writing a Macro

Post by UnklDonald418 »

As you noted, when recording a macro in Calc, you must use keyboard commands to move from cell to cell and <Ctrl>C (or <Ctrl>X) for Copy and <Ctrl>V for Paste.
If you are more specific about what isn't working for you perhaps someone could help.
Be aware that some operations are not possible with a recorded macro. however, writing macro code is far more difficult.
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
ptownpapa
Posts: 24
Joined: Mon Oct 09, 2017 2:58 am

Re: Writing a Macro

Post by ptownpapa »

I guess what I'm asking - just what is "acceptable" in a Macro - I used =sum() and copy/paste, pretty simple stuff - another question - if I use Ctrl V to paste how do I indicate Paste Special? Can I copy/paste part of a column?
openoffice 4.1.3 on Wndows 10
UnklDonald418
Volunteer
Posts: 1549
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Writing a Macro

Post by UnklDonald418 »

Select Help on a Calc page and on the Find tab enter Shortcut Keys for Spreadsheets as the Search Item. Double click on result of the search to display all the available keyboard commands.
On the main Calc menu Select Edit and look at Paste Special to see the key combination.
If you want to copy a range of cells, hold down the Shift key while you navigate using the arrow keys.
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
User avatar
MrProgrammer
Moderator
Posts: 4906
Joined: Fri Jun 04, 2010 7:57 pm
Location: Wisconsin, USA

Re: Writing a Macro

Post by MrProgrammer »

ptownpapa wrote:I guess what I'm asking - just what is "acceptable" in a Macro
FAQ Macros
Some keyboard operations aren't recorded and some mouse operations are recorded, however, in very general terms, you are more likely to succeed if you perform only keyboard operations.
ptownpapa wrote:how do I indicate Paste Special?
Edit → Paste Special → {make dialog choices} → OK
It will probably be fine to select the menus and dialog choices with the mouse if you don't know how to use your keyboard for that.

If this solved your problem please go to your first post use the Edit button and add [Solved] to the start of the title. You can select the green checkmark icon at the same time.
Mr. Programmer
AOO 4.1.7 Build 9800, MacOS 13.6.3, iMac Intel.   The locale for any menus or Calc formulas in my posts is English (USA).
ptownpapa
Posts: 24
Joined: Mon Oct 09, 2017 2:58 am

Re: Writing a Macro

Post by ptownpapa »

Yes.. ctrl-shift-V .. is paste special - How many of the community of PC users use keyboard commands any more? My intro to GUI was Windows 3.1
I am using the KEYBOARD - I TRY to record this simple function =sum(D2*-1) I then STOP RECORDING and save the "macro" - I then close the spreadsheet and reopen it - I RUN the macro and nothing happens. I have read help, FAQ and I am not enlightened. Someone please point me in the right direction. I am frustrated, but I appreciate the responses so far and I thank you all.
openoffice 4.1.3 on Wndows 10
UnklDonald418
Volunteer
Posts: 1549
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Writing a Macro

Post by UnklDonald418 »

In Chapter 13 of “Getting Started with OpenOffice”
https://wiki.openoffice.org/wiki/Docume ... ser_Guide_
Under the heading “Sometimes the macro recorder fails” I found
Other possible problems using the macro recorder include things such as inserting a formula, setting user data, setting filters in Calc, actions in database forms, and exporting a document to an encrypted PDF file. You never know for certain what will work unless you try it, however. The actions from the search dialog are properly captured, for example.
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Writing a Macro

Post by Villeroy »

Why do you want to write a spreadsheet macro before you even started to use a spreadsheet properly? It makes no sense at all.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
ptownpapa
Posts: 24
Joined: Mon Oct 09, 2017 2:58 am

Re: Writing a Macro

Post by ptownpapa »

UnklDonald... this is Huey, it makes no sense that a tool MAY not work - But that's the way of the computer.

I have the Guide open and it references editing and other wonderful things all of which I would love to pursue but I gave up staying up all night coding 13 years ago. I now futz and fiddle with easy stuff, like macro's that sometimes don't work. Thank you for the insight.

Villeroy I am lost - I can only assume your response was meant as a riposte. Not complaining just missed the point. And thank you for being a volunteer.
openoffice 4.1.3 on Wndows 10
UnklDonald418
Volunteer
Posts: 1549
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: [Solved] Writing a Macro

Post by UnklDonald418 »

Villeroy is correct. Even though your formula appears to work it is incorrectly formatted and why would you want to SUM a single cell?
Try recording a macro where you type =SUM(D1:D2) * -1 or if you want just one cell =D2 * -1
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
ptownpapa
Posts: 24
Joined: Mon Oct 09, 2017 2:58 am

Re: [Solved] Writing a Macro

Post by ptownpapa »

Habit....
openoffice 4.1.3 on Wndows 10
User avatar
Zizi64
Volunteer
Posts: 11359
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: [Solved] Writing a Macro

Post by Zizi64 »

I assumed, ha ha, that when it said "record macro" I simply entered the commands etc and "stopped recording" and saved it.
When I said "run macro" to my surprise it went through the motions - going from cell to cell - but no data was moved or modified.
I read the instructions, noted the admonition about keyboard not mouse, tried that still no go.
What have I missed?? Please help.
The Macro Recorder of the AOO and Lo has a (very) limited capability. You must write your macros, instead of record them - if you want work efficiently with the macros in the open source office suites.

I am using the KEYBOARD - I TRY to record this simple function =sum(D2*-1) I then STOP RECORDING and save the "macro" - I then close the spreadsheet and reopen it - I RUN the macro and nothing happens.
You can put a formula into a desired cell by using the API functions. (there are sample codes in this forum):
viewtopic.php?f=45&t=55214
http://ooo-forums.apache.org/en/forum/v ... 10#p424246

You need study and use the API (Application Programming Interface) functions.
There is not any other way.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
Post Reply