Bug 149560 - Excel Visual Basic compatibility issue in LibreOffice Calc: Round trip produces a corrupt xls file
Summary: Excel Visual Basic compatibility issue in LibreOffice Calc: Round trip produc...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
7.3.4.2 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: filter:xls
Depends on:
Blocks: Macro-VBA
  Show dependency treegraph
 
Reported: 2022-06-14 08:32 UTC by Óvári
Modified: 2023-01-20 08:18 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
button2macro.xls (44.50 KB, application/vnd.ms-excel)
2022-06-14 08:34 UTC, Óvári
Details
button2macro.ods (11.78 KB, application/vnd.oasis.opendocument.spreadsheet)
2022-06-14 08:35 UTC, Óvári
Details
button2macroback.xls (8.50 KB, application/vnd.ms-excel)
2022-06-14 08:35 UTC, Óvári
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Óvári 2022-06-14 08:32:22 UTC
Description:
Using LibreOffice Calc, a round trip from .xls to .ods to .xls doesn't work for a Excel spreadsheet with a simple button which runs a subroutine that shows a message box.

Steps to Reproduce:
An Excel button2macro.xls spreadsheet file with a button that runs macro
MsgBox "Hello World!"

With LibreOffice Calc, save the button2macro.xls file as button2macro.ods.
Clicking the "Button 1" shows the "Hello World!" dialog box.

Close LibreOffice.

With LibreOffice Calc, save the button2macro.ods file as button2macroback.xls.

Open the button2macroback.xls with Microsoft Excel 2010 and a dialog shows with a message:
```
Office has detected a problem with this file. To help
protect your computer this file cannot be opened.
```

LibreOffice Calc 7.3.4.2 opens the button2macroback.xls file and it works most of the time; however, there was a time when the file opened and the button was clicked and it didn't work with the message:
```
A Scripting Framework error occurred while running the UNKNOWN script UNKNOWN.

Message: Incorrecct format for Script URI: /run/build/libreoffice/scripting/source/provider/MasterScriptProvider.css:238
```
Perhaps the MasterScriptProvider.css:238 can help with finding a solution so a round trip of a VBA file is achievable.

Actual Results:
Open the button2macroback.xls with Microsoft Excel 2010 and a dialog shows with a message:
```
Office has detected a problem with this file. To help
protect your computer this file cannot be opened.
```

Expected Results:
The button2macroback.xls spreadsheet file should be able to be opened with Microsoft Excel 2010.


Reproducible: Always


User Profile Reset: No



Additional Info:
The Excel button2macro.xls spreadsheet file will be attached as later as unsure how to attach it now.

Will help with bug 149325.

Thank you
Comment 1 Óvári 2022-06-14 08:34:30 UTC
Created attachment 180746 [details]
button2macro.xls
Comment 2 Óvári 2022-06-14 08:35:04 UTC
Created attachment 180747 [details]
button2macro.ods
Comment 3 Óvári 2022-06-14 08:35:28 UTC
Created attachment 180748 [details]
button2macroback.xls
Comment 4 Buovjaga 2023-01-20 08:18:25 UTC
I confirm with office.com

Arch Linux 64-bit, X11
Version: 7.6.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 4c06cfcd13195e9e996bc09dbee2dcac1c5e8ed2
CPU threads: 8; OS: Linux 6.1; UI render: default; VCL: kf5 (cairo+xcb)
Locale: fi-FI (fi_FI.UTF-8); UI: en-US
Calc: threaded
Built on 20 January 2023

(In reply to Óvári from comment #0)
> ```
> A Scripting Framework error occurred while running the UNKNOWN script
> UNKNOWN.
> 
> Message: Incorrecct format for Script URI:
> /run/build/libreoffice/scripting/source/provider/MasterScriptProvider.css:238
> ```

The code block is:

// need to get the language from the string

Reference< uri::XUriReferenceFactory > xFac ( uri::UriReferenceFactory::create( m_xContext )  );

Reference<  uri::XUriReference > uriRef = xFac->parse( scriptURI );

Reference < uri::XVndSunStarScriptUrl > sfUri( uriRef, UNO_QUERY );

if ( !uriRef.is() || !sfUri.is() )
{
    throw provider::ScriptFrameworkErrorException(
        "Incorrect format for Script URI: " + scriptURI,
        Reference< XInterface >(),
        scriptURI, "",
        provider::ScriptFrameworkErrorType::UNKNOWN );
}