[Solved] Writing a Macro

Creating a macro - Writing a Script - Using the API

[Solved] Writing a Macro

Postby ptownpapa » Wed Jul 04, 2018 4:10 pm

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
ptownpapa
 
Posts: 15
Joined: Mon Oct 09, 2017 2:58 am

Re: Writing a Macro

Postby UnklDonald418 » Wed Jul 04, 2018 4:49 pm

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.6 & LibreOffice 6.1.5.2 - Windows 10 Professional
UnklDonald418
Volunteer
 
Posts: 1152
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Writing a Macro

Postby ptownpapa » Wed Jul 04, 2018 5:20 pm

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
ptownpapa
 
Posts: 15
Joined: Mon Oct 09, 2017 2:58 am

Re: Writing a Macro

Postby UnklDonald418 » Wed Jul 04, 2018 9:00 pm

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.6 & LibreOffice 6.1.5.2 - Windows 10 Professional
UnklDonald418
Volunteer
 
Posts: 1152
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Writing a Macro

Postby MrProgrammer » Wed Jul 04, 2018 9:07 pm

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.5 Build 9789 on MacOS 10.11.6.   The locale for any menus or Calc formulas in my posts is English (USA).
User avatar
MrProgrammer
Moderator
 
Posts: 3709
Joined: Fri Jun 04, 2010 7:57 pm
Location: Wisconsin, USA

Re: Writing a Macro

Postby ptownpapa » Thu Jul 05, 2018 5:36 pm

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
ptownpapa
 
Posts: 15
Joined: Mon Oct 09, 2017 2:58 am

Re: Writing a Macro

Postby UnklDonald418 » Thu Jul 05, 2018 8:05 pm

In Chapter 13 of “Getting Started with OpenOffice”
https://wiki.openoffice.org/wiki/Documentation/OOo3_User_Guides/OOo3.3_User_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.6 & LibreOffice 6.1.5.2 - Windows 10 Professional
UnklDonald418
Volunteer
 
Posts: 1152
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Writing a Macro

Postby Villeroy » Thu Jul 05, 2018 8:08 pm

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, no OpenOffice, LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 26731
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Writing a Macro

Postby ptownpapa » Thu Jul 05, 2018 9:08 pm

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
ptownpapa
 
Posts: 15
Joined: Mon Oct 09, 2017 2:58 am

Re: [Solved] Writing a Macro

Postby UnklDonald418 » Thu Jul 05, 2018 10:00 pm

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.6 & LibreOffice 6.1.5.2 - Windows 10 Professional
UnklDonald418
Volunteer
 
Posts: 1152
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: [Solved] Writing a Macro

Postby ptownpapa » Thu Jul 05, 2018 11:23 pm

Habit....
openoffice 4.1.3 on Wndows 10
ptownpapa
 
Posts: 15
Joined: Mon Oct 09, 2017 2:58 am

Re: [Solved] Writing a Macro

Postby Zizi64 » Fri Jul 06, 2018 7:25 am

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):
https://forum.openoffice.org/en/forum/v ... 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; LO4.4.7, LO6.1.6 on Win7-10 x64Prof.
PortableApps, winPenPack: LO3.3.0-6.2.4; AOO4.1.5
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.
User avatar
Zizi64
Volunteer
 
Posts: 7973
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 6 guests