cwolan wrote: ↑Sat Jun 15, 2024 8:52 pm
1. "then" seems inappropriate.
Changed to:
Recording macros is much simpler than writing them.
cwolan wrote: ↑Sat Jun 15, 2024 8:52 pm
2. PasteFormat appears twice, although PasteFormats was suggested earlier in the Tutorial.
Changed to
PasteFormats in both sentences.
cwolan wrote: ↑Sat Jun 15, 2024 8:52 pm
3. When I record these steps, the resulting macro contains two inactive lines (with the framework commands).
I looked at the actual macro that I use, shown below. Perhaps I recorded it, realized it didn't do what I wanted, edited it, became accustomed to using it, and bound it to ⇧⌘C. I probably created it about ten years ago. From the name, its
original purpose was to copy the text in a cell to the clipboard without the terminating newline. Earlier attempts to do that were more complicated, involving a MacOS
service which I wrote to discard the last newline on the clipboard. So I needed to do Copy, run service, Paste.
Though not the original purpose, I realized the macro was also useful for copying the
text of a formula to the clipboard. I use it with Safari so I can copy a formula from a cell and then paste its text (rather than its value) into a forum topic: select cell, ⇧⌘C. And I use with Calc it to copy a formula, without changing relative references, from one cell to another. This is easier than the technique in paragraph
One can duplicate a formula … of
[Tutorial] Formula Adjustments during Copy and Move. I use it more now for this secondary purpose and in my mind the macro is CopyText instead of NoNL.
Then later, perhaps after reading a topic in the forum, I thought this macro could be useful for others and I added it to the tutorial, forgetting that an edit was needed. I think I will just remove CopyText from the tutorial since it's purpose is to show what can be done without having to know how to write/edit macros.
Sub NoNL ' ⇧⌘C Copy cell contents to clipboard without terminating NewLine
Rem This macro also can be used to copy a cell's formula
Dim dispatch As Object : dispatch = createUnoService("com.sun.star.frame.DispatchHelper")
Dim document As Object : document = ThisComponent.CurrentController.Frame
dispatch.executeDispatch(document, ".uno:SetInputMode", "", 0, Array())
dispatch.executeDispatch(document, ".uno:SelectAll", "", 0, Array())
dispatch.executeDispatch(document, ".uno:Copy", "", 0, Array())
dispatch.executeDispatch(document, ".uno:Cancel", "", 0, Array())
End Sub
Thank you for helping to improve the tutorial,
cwolan.
Mr. Programmer
AOO 4.1.7 Build 9800, MacOS 13.7, iMac Intel. The locale for any menus or Calc formulas in my posts is English (USA).