Bug 151393

Summary: Auto_Open should not run from ThisWorkbook
Product: LibreOffice Reporter: Justin L <jluth>
Component: CalcAssignee: Justin L <jluth>
Status: RESOLVED FIXED    
Severity: normal CC: jluth, quikee
Priority: medium Keywords: bibisected, bisected, regression
Version: 7.4.0.0 alpha0+   
Hardware: All   
OS: All   
Whiteboard: target:7.5.0
Crash report or crash signature: Regression By:
Bug Depends on:    
Bug Blocks: 108908    
Attachments: autoOpenClose.xls: various oddities with auto_open in Excel

Description Justin L 2022-10-06 18:00:27 UTC
Created attachment 182883 [details]
autoOpenClose.xls: various oddities with auto_open in Excel

The auto_ functions are not supposed to run from ThisWorkbook (Excel 2003/2010).

This changed in LO 7.4 with commit beb6c62e990599d91ac5d9183164c94d269027d3
Author: Tomaž Vajngerl on Mon Jan 31 15:46:30 2022 +0900
    vba: fix registering shortcuts keys defined by the vba macros
Comment 1 Justin L 2022-10-06 18:05:17 UTC
Steps to reproduce
1.) Open autoOpenClose.xls and allow macros to run
2.) Accept MsgBox from ThisWorkbook.WorkBook_Open macro.
3.) That should be it. However, we have a second msgbox opening for ThisWorkbook.auto_open. This second one should not run (tested Excel 2010/2003).
Comment 2 Justin L 2022-10-07 20:08:24 UTC
Prior to Tomaž' patch, hasMacro could return true if
sMod.isEmpty() and a Module named sMacroName has a "Main" macro.

I think that might have been for MS Word's benefit. At least AutoOpen works that way (although our code didn't get the macroURL right). It is probably better that it doesn't return true, but just noting the difference.
Comment 3 Commit Notification 2022-10-11 18:39:36 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

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

tdf#148806 tdf#151393 xls vba: no Auto_Open from ThisWorksheet

It will be available in 7.5.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.