Hi!
I’m currently stumbling on a strange problem w/r copying formats between ranges in Calc by macro in BASIC.
I’ve searched numerous sources (the Ask pages, the usual suspects like Andrew Pitonyak’s documentations, etc.) to no avail. The Ask pages I found do not apply to the situation at hand. Not sure whether I’m goofing or there’s something else here.
I attach a demo document showing the problem:
test_copy_formats.ods (31.9 KB)
.
Tested under LibreOffice 7.3.6 under LinuwMint 20.3 Cinnamon
and LibreOffice 7.5 under Windows 10.
Clicking any of the two buttons doesn’t give the expected result. Button v1 code was given by the macro recorder. Button v2 is a mix of API calls and macro recorded.
Expected: C1:C10 range format is copied to B1:B10 range.
Actual result: B1:B10 receives whatever format the clipboard contents hold (see details in the document).
A quick process analyze shows that the problem comes from the .uno:Copy
instruction which doesn’t apply.
Can any knowledgeable soul help on this matter?
This is a reduced calc spreadsheet for demo.
The actual overall process is:
- Column R is used for data entering
- When validated, a column is added to the right (-> S)
- and the data in R copied to S
- Then the R column contents is cleared, ready for new data.
As (1) R and S have different formats and (2) inserting a column copies the format from the one at its left (iow, at insertion time, S receives the R format), I must update the S format from column T in order to keep the overall aspect.
Everything works OK, except for that format copy.
Please note that, though I am sure a database actually is the solution, I’m given that spreadsheet to handle as-is and can not switch to something else.
Hence the format question…
Thanks for any hint!