Bug 167378 - Copying a Date cell from one sheet to another with a macro doesn't work anymore with Version 25.2.4.3
Summary: Copying a Date cell from one sheet to another with a macro doesn't work anymo...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
25.2.4.3 release
Hardware: x86-64 (AMD64) Windows (All)
: medium normal
Assignee: Mike Kaganski
URL:
Whiteboard: target:26.2.0 target:25.8.0.0.beta2
Keywords:
Depends on:
Blocks:
 
Reported: 2025-07-04 10:13 UTC by Juerg Beck
Modified: 2025-07-04 19:10 UTC (History)
0 users

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Juerg Beck 2025-07-04 10:13:52 UTC
Description:
Up to my previously used version 24.8.7 I copied date cells with format 'YYYY-MM-DD' with the following code snippet:
Dim DataCellDate as Date
Worksheets("NeueFounds").Cells(IRow, 16).NumberFormat = "YYYY-MM-DD"
DataCellDate = Worksheets("NeueFounds").Cells(IRow, 16).Value
Worksheets("FoundCaches").Cells(IRow + 1, 11).NumberFormat = "YYYY-MM-DD"
Worksheets("FoundCaches").Cells(IRow + 1, 11).Value = DataCellDate

With version 25.2.4.3 this results in an empty cell
If I specify the variable DataCellDate  as String the resulting cell has a date with exchanged month and date. 2025-07-04 gets 2025-04-07

Steps to Reproduce:
Code snippet in the description

Actual Results:
resulting cell is empty

Expected Results:
Cell value should be a copy of the source cell


Reproducible: Always


User Profile Reset: No

Additional Info:
Version: 25.2.4.3 (X86_64) / LibreOffice Community
Build ID: 33e196637044ead23f5c3226cde09b47731f7e27
CPU threads: 8; OS: Windows 11 X86_64 (10.0 build 26100); UI render: Skia/Raster; VCL: win
Locale: en-GB (de_CH); UI: en-GB
Calc: threaded
Comment 1 Mike Kaganski 2025-07-04 10:45:31 UTC
(In reply to Juerg Beck from comment #0)
> Description:
> Up to my previously used version 24.8.7 I copied date cells with format
> 'YYYY-MM-DD' with the following code snippet:
> Dim DataCellDate as Date
> Worksheets("NeueFounds").Cells(IRow, 16).NumberFormat = "YYYY-MM-DD"
> DataCellDate = Worksheets("NeueFounds").Cells(IRow, 16).Value
> Worksheets("FoundCaches").Cells(IRow + 1, 11).NumberFormat = "YYYY-MM-DD"
> Worksheets("FoundCaches").Cells(IRow + 1, 11).Value = DataCellDate
> 
> ...
> 
> Steps to Reproduce:
> Code snippet in the description

Copying the snippet to a Basic function, and running it as is, doesn't work. Either provide a working code, or maybe a ODS with a macro ready to run.
Comment 2 Mike Kaganski 2025-07-04 12:03:27 UTC
I found a way to reproduce (it didn't occur to me, that it was a VBA, which required that the code is in the document, otherwise workarounds are required to get into the context of current document). Please note, that providing a truly working sample makes it easier for others to reproduce, which may severely affect a possible fix.
Comment 3 Mike Kaganski 2025-07-04 12:12:47 UTC
https://gerrit.libreoffice.org/c/core/+/187393
Comment 4 Commit Notification 2025-07-04 15:04:59 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/e90e4b81b049a9d7c36de8d7f0371e2da7c60c01

tdf#167378: handle css::bridge::oleautomation::Date in CellValueSetter

It will be available in 26.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 5 Commit Notification 2025-07-04 15:06:01 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/a3052d87e1c9f8c8843f453a09b88c6eeb0febab

Related: tdf#167378 Set cells' number format when assigning dates

It will be available in 26.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 6 Commit Notification 2025-07-04 19:10:47 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "libreoffice-25-8":

https://git.libreoffice.org/core/commit/ad76806524aae8c07481b0e4133c24f20c4fc687

tdf#167378: handle css::bridge::oleautomation::Date in CellValueSetter

It will be available in 25.8.0.0.beta2.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.