Bug 120374 - FILESAVE XLSM: VBA button doesn't execute linked macro after round-trip
Summary: FILESAVE XLSM: VBA button doesn't execute linked macro after round-trip
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Justin L
URL:
Whiteboard: target:7.6.0
Keywords:
Depends on:
Blocks: Macro-VBA
  Show dependency treegraph
 
Reported: 2018-10-07 11:05 UTC by Nikolai
Modified: 2023-02-22 15:34 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
File that reproduces the issue (39.75 KB, application/zip)
2018-10-07 11:06 UTC, Nikolai
Details
webster-sainte-lague-calculator.xls: Excel 2010 roundtrip of attachment 145441 (66.00 KB, application/vnd.ms-excel)
2023-01-21 19:30 UTC, Justin L
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nikolai 2018-10-07 11:05:47 UTC
Description:
In an .xlsm document with a macro tied to a button, the button disappears upon saving the document.

Steps to Reproduce:
1. Open attached file. Make sure macros are enabled.
2. Click "Edit document".
3. Edit a cell.
4. Edit -> Edit Mode.
5. You're prompted to save. Click Save.
6. Save as .xlsm.

Actual Results:
Green button disappears.

Expected Results:
Green button should remain and work as before.


Reproducible: Always


User Profile Reset: Yes



Additional Info:
Comment 1 Nikolai 2018-10-07 11:06:28 UTC
Created attachment 145441 [details]
File that reproduces the issue
Comment 2 MM 2018-10-07 23:07:40 UTC
Confirmed on windows 7 x64 with Version: 6.0.7.1 (x64)
Build ID: 5d2cb2a5dd04fe174b336488731eb50bbb5faed3
CPU threads: 3; OS: Windows 6.1; UI render: default

and ubuntu 16.04 x64 with Version: 5.1.6.2
Build ID: 07ac168c60a517dba0f0d7bc7540f5afa45f0909
CPU Threads: 2; OS Version: Linux 4.4; UI Render: default; 
Locale: en-US (en_US.UTF-8); Calc: single

Saving as xlsm and xlsx loses the button. Saving as xls is fine, only the button is grey instead of green.
Comment 3 QA Administrators 2019-10-08 02:28:42 UTC Comment hidden (obsolete)
Comment 4 Nikolai 2019-10-08 09:25:28 UTC
The bug is still present.

Version: 6.3.2.2 (x64)
Build ID: 98b30e735bda24bc04ab42594c85f7fd8be07b9c
CPU threads: 8; OS: Windows 10.0; UI render: default; VCL: win; 
Locale: en-GB (en_GB); UI-Language: en-GB
Calc: threaded
Comment 5 Timur 2021-09-22 10:58:41 UTC
Repro 7.3+.
Let's consider a duplicate so far.

*** This bug has been marked as a duplicate of bug 117266 ***
Comment 6 Justin L 2023-01-21 16:46:43 UTC
This was mostly fixed by commits for bug 117266. The buttons no longer disappear on a round-trip. However, the macro doesn't execute - probably because "ThisWorkbook" has been duplicated. (That is also true in bug 124203.)

Removing as duplicate, since the broken VBA is not necessarily due to the same reason as any of the others.

Round-tripping as XLS didn't work and exhibits the same duplicate ThisWorkbook1 (at least as seen in Excel 2003).

Manually running the macro code in LO works - so perhaps the first thing to look into is why the macro-link is lost on the button. Perhaps that is caused by something different than some of the other export issues? Ahh, probably the name changed. It is based on a <name>_Click macro. In the round-trip it is just getting a numberId and is losing the spid connection. So some of the name-related commits in bug 117266 weren't good enough.
Comment 7 Justin L 2023-01-21 19:30:10 UTC
Created attachment 184825 [details]
webster-sainte-lague-calculator.xls: Excel 2010 roundtrip of attachment 145441 [details]

Note: starting from an Excel-created XLS and round-tripping that as XLS works fine.
Comment 8 Commit Notification 2023-01-24 02:10:52 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/245912dc42bfc13cbf0db3f04f2411f3dede9615

tdf#117266 tdf#120374 sc oox: export correct vml button name #2

It will be available in 7.6.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 9 Justin L 2023-01-26 22:47:10 UTC
The beautiful green colour is lost, but the macro button exists and is still functional after multiple round-trips. I'll mark it as fixed.

What does NOT work is .xls -> .xlsm, or .xlsm -> .xls. However, those are fairly different internal binary changes IIUC, so that doesn't surprise me. The fact that it can simply round-trip is already rather impressive.