Page 1 of 1
[Solved] Recorded macro doesn't perform copy paste steps
Posted: Tue Jan 30, 2024 6:25 pm
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
Re: Macros unable to reproduce copy paste steps in LibreOffice 7.6.4.1 Windows 10 64 bit
Posted: Tue Jan 30, 2024 9:06 pm
by Zizi64
Can you upload the recorded macro code embedded into a sample file?
Re: Macros unable to reproduce copy paste steps in LibreOffice 7.6.4.1 Windows 10 64 bit
Posted: Wed Jan 31, 2024 4:33 pm
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.
Re: Macros unable to reproduce copy paste steps in LibreOffice 7.6.4.1 Windows 10 64 bit
Posted: Wed Jan 31, 2024 6:47 pm
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
Re: Macros unable to reproduce copy paste steps in LibreOffice 7.6.4.1 Windows 10 64 bit
Posted: Thu Feb 01, 2024 8:04 am
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())
Re: Macros unable to reproduce copy paste steps in LibreOffice 7.6.4.1 Windows 10 64 bit
Posted: Thu Feb 01, 2024 8:35 am
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.
Re: Macros unable to reproduce copy paste steps in LibreOffice 7.6.4.1 Windows 10 64 bit
Posted: Thu Feb 01, 2024 11:14 pm
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.
Re: Macros unable to reproduce copy paste steps in LibreOffice 7.6.4.1 Windows 10 64 bit
Posted: Sat Feb 03, 2024 1:19 am
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.
Re: [Solved] Recorded macro doesn't perform copy paste steps
Posted: Wed Feb 14, 2024 11:37 am
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.