[Solved] Recorded macro doesn't perform copy paste steps

Help with installation and general system troubleshooting questions concerning the office suite LibreOffice.
Locked
4joey1
Posts: 1
Joined: Tue Jan 30, 2024 6:18 pm

[Solved] Recorded macro doesn't perform copy paste steps

Post by 4joey1 »

Hi,

I have LibreOffice 7.6.4.1 (I think this is the latest version) installed on Windows 10 64 bit.

I recorded a macro in LibreOffice Calc where I selected several cells,right clicked my mouse and selected copy,put my mouse pointer on an empty cell and right clicked and selected paste special number or even transpose and saved the macro.

When I opened a new document an tried running the macro,it could not reproduce the simple copy paste steps.I am shocked by this as I assumed that this is an obvious task that macros should be able to record and reproduce.

Please help me in fixing this.

Thanks
Last edited by MrProgrammer on Fri Feb 09, 2024 5:20 pm, edited 1 time in total.
LibreOffice 7.6.4.1 on Windows 10 64 bit
User avatar
Zizi64
Volunteer
Posts: 11364
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Macros unable to reproduce copy paste steps in LibreOffice 7.6.4.1 Windows 10 64 bit

Post by Zizi64 »

Can you upload the recorded macro code embedded into a sample file?
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.
User avatar
Lupp
Volunteer
Posts: 3553
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Macros unable to reproduce copy paste steps in LibreOffice 7.6.4.1 Windows 10 64 bit

Post by Lupp »

@4joey1, as this seems to be your first post, welcome to the forum.

And a few remarks:
1. The OO.o version your signature is showing is very old. So is the Win version. There may not still be many ucontributors knowing any special problems related to that combination.
2. The subject of your post mentions "LibreOffice 7.6.4.1 Windows 10 64 bit". This is inconsistent and requires clarification.
3. You didn't post earlier. If you never had an issue up to now, you also may never have used the macro recorder. It may therefore be that you expect a recorded macro to be waiting for your actions during execution, and then continuing depending on them. This is a wrong expectation. Therefore any contibutor will need to study your code before they can advise you reasonably.
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
User avatar
MrProgrammer
Moderator
Posts: 4909
Joined: Fri Jun 04, 2010 7:57 pm
Location: Wisconsin, USA

Re: Macros unable to reproduce copy paste steps in LibreOffice 7.6.4.1 Windows 10 64 bit

Post by MrProgrammer »

4joey1 wrote: Tue Jan 30, 2024 6:25 pm I have LibreOffice 7.6.4.1 installed on Windows 10 64 bit
Your forum signature is: OpenOffice 3.1 on Windows Vista. Please fix that.

4joey1 wrote: Tue Jan 30, 2024 6:25 pm … or even transpose …
I don't know what you mean by that phrase. I ignored it.

4joey1 wrote: Tue Jan 30, 2024 6:25 pm I selected several cells, … selected copy, [selected] an empty cell, … selected paste special number … and saved the macro.
Read [Tutorial] Favorite Recorded Calc Macros. Your description sounds similar to PasteValues there. I recorded it years ago and use PasteValues many times a week.

A recorded macro cannot make, or ask you to make, any decisions. Every step in a recorded macro is a fixed, imperative action. If you record selecting the source cell and the target cell, the macro will always act on those same cells. Perhaps you don't want to do that. When I created PasteValues, I recorded only the Paste Special part so that I have flexibility in what the source and target are.

4joey1 wrote: Tue Jan 30, 2024 6:25 pm When I opened a new document an tried running the macro,it could not reproduce the simple copy paste steps.
If you need the macro to be available in a new document, you must save it in My Macros, not in a Calc document.

If this solved your problem please go to your first post use the Edit button and add [Solved] to the start of the Subject field. Select the green checkmark icon at the same time.

[Tutorial] Ten concepts that every Calc user should know
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).
cwolan
Posts: 129
Joined: Sun Feb 07, 2021 3:44 pm

Re: Macros unable to reproduce copy paste steps in LibreOffice 7.6.4.1 Windows 10 64 bit

Post by cwolan »

4joey1 wrote: Tue Jan 30, 2024 6:25 pm I recorded a macro in LibreOffice Calc where I selected several cells,right clicked my mouse and selected copy,put my mouse pointer on an empty cell and right clicked and selected paste special number or even transpose and saved the macro.
FWIW:
In LibreOffice 7.6.4.1, the Paste Special menu contains 6 items.
In case of: "Text", "Number", "Formula" and "Transpose"
the Macro Recorder provides a commented out code.

E.g. for the "Number" item:

Code: Select all

rem ----------------------------------------------------------------------
rem dispatcher.executeDispatch(document, ".uno:PasteOnlyValue", "", 0, Array())
OpenOffice 1.1.5 – 4.1.15
LibreOffice 3.3.0.4 – 7.6.6
Windows 7,10,11 64-bit
User avatar
robleyd
Moderator
Posts: 5087
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: Macros unable to reproduce copy paste steps in LibreOffice 7.6.4.1 Windows 10 64 bit

Post by robleyd »

Cross posted at AskLibreOffice

If you cross post, as a courtesy please let us know that you have done so, otherwise it leads to several discussions and a waste of time because several identical answers may be posted by different users.
Cheers
David
OS - Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.2.2.2; SlackBuild for 24.2.2 by Eric Hameleers
User avatar
Lupp
Volunteer
Posts: 3553
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Macros unable to reproduce copy paste steps in LibreOffice 7.6.4.1 Windows 10 64 bit

Post by Lupp »

To get recorded code to adapt its working better to your needs, you have to edit it introducing substantial changes and enhancements.
On the other hand some wanted adaptions of action are better supported by some .uno: commands than by standard API means. This seems to be the case of "pasting special" with flags.
See attached example.
aoo111199verySpecialPasteSpecial.ods
(17.58 KiB) Downloaded 77 times
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
User avatar
MrProgrammer
Moderator
Posts: 4909
Joined: Fri Jun 04, 2010 7:57 pm
Location: Wisconsin, USA

Re: Macros unable to reproduce copy paste steps in LibreOffice 7.6.4.1 Windows 10 64 bit

Post by MrProgrammer »

cwolan wrote: Thu Feb 01, 2024 8:04 am In LibreOffice 7.6.4.1, the Paste Special menu contains 6 items.
In case of: "Text", "Number", "Formula" and "Transpose"
the Macro Recorder provides a commented out code.
But the last of the six items, Edit → Paste Special → Paste Special, does create executable code (not a comment) in the recorded macro. Thus when recording a macro don't use Text, Number, Formula, or Transpose since the last Paste Special item allows one to perform all of those four operations. The macro which I recorded with Edit → Paste Special → Paste Special → Selection:Numbers → Options:None → Operations:None → ShiftCells:Don't → OK copied the numeric value only.

I have no idea why the developers would implement these new features without providing recorded macro support. Seems to me as if there is room for improvement in the implementation of them. Generating the comment is not helpful because the recorded macro feature is designed for people who are not able to write macros using the API, that is, almost every user. Many users don't have the programming background to make even trivial changes to a recorded macro.

If this solved your problem please go to your first post use the Edit button and add [Solved] to the start of the Subject field. 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).
cwolan
Posts: 129
Joined: Sun Feb 07, 2021 3:44 pm

Re: [Solved] Recorded macro doesn't perform copy paste steps

Post by cwolan »

Amen to that!

(Ab)using the phrase from LO 7.6 Getting Started Guide (p. 429):
You never know for certain what the macro recorder can capture until you try it.
OpenOffice 1.1.5 – 4.1.15
LibreOffice 3.3.0.4 – 7.6.6
Windows 7,10,11 64-bit
Locked