Bug 118247 - FILEOPEN XLSX Basic code with SpecialCells(xlCellTypeConstants, 1) range method is ignored
Summary: FILEOPEN XLSX Basic code with SpecialCells(xlCellTypeConstants, 1) range meth...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
4.3.0.4 release
Hardware: All All
: medium normal
Assignee: Andreas Heinisch
URL:
Whiteboard: target:7.5.0
Keywords:
Depends on:
Blocks: Macro-VBA
  Show dependency treegraph
 
Reported: 2018-06-19 16:37 UTC by Gabor Kelemen (allotropia)
Modified: 2022-09-06 09:36 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Example file from Excel (25.70 KB, application/vnd.ms-excel.sheet.macroEnabled.12)
2018-06-19 16:37 UTC, Gabor Kelemen (allotropia)
Details
Result of the macro in Excel and Calc side by side (104.51 KB, image/png)
2018-06-19 16:40 UTC, Gabor Kelemen (allotropia)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gabor Kelemen (allotropia) 2018-06-19 16:37:38 UTC
Created attachment 142932 [details]
Example file from Excel

If we use XlSpecialCells range method in visual basic code created by Microsoft Excel 2013/2016, and open with LibreOffice Calc and run the macro, the “SpecialCells(xlCellTypeConstants, 1)” method is ignored.

Steps to reproduce:
1. Create a new spreadsheet with Microsoft Excel 2016/2013
2. Fill a range (for example A1:V30) with numbers and letters
3. Open the Visual Basic window
3. Add a new Module to your VBAProject
4. Copy this VBA code to your module:

Sub kijeloles_adatok()
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.SpecialCells(xlCellTypeConstants, 1).Select
With Selection.Interior
    .Pattern = xlSolid
    .Color = 5287936
End With
ActiveSheet.Range("A1").Select
End Sub

5. Save the file as *.xlsm
6. Open the file in LibreOffice Calc and run the macro.


Actual results:
The macro is run without an error, but the Selection.SpecialCells(xlCellTypeConstants, 1) method was ignored. Instead of filling the numbers with color the macro fills all the range with color.

Expected results:
The SpecialCells(xlCellTypeConstants, 1) method should work correctly.


Version: 6.0.0.0.beta1+
Build ID: 29228e83df009cf76ac819ed024527be1092f065
CPU threads: 4; OS: Windows 6.1; UI render: default; 
TinderBox: Win-x86@42, Branch:libreoffice-6-0, Time: 2017-12-04_23:15:34
Locale: hu-HU (hu_HU); Calc: group threaded
Comment 1 Gabor Kelemen (allotropia) 2018-06-19 16:40:10 UTC
Created attachment 142933 [details]
Result of the macro in Excel and Calc side by side
Comment 2 Buovjaga 2018-06-24 18:52:12 UTC
Repro.

Arch Linux 64-bit
Version: 6.2.0.0.alpha0+
Build ID: 5b42a17dc99fba2ccf8dd8d0a8e0e4e836e30120
CPU threads: 8; OS: Linux 4.17; UI render: default; VCL: kde4; 
Locale: fi-FI (fi_FI.UTF-8); Calc: group threaded
Built on June 22nd 2018

Win 10
Version: 4.3.0.0.beta1
Build ID: b7cfa1eab1cb1e94f71d6df6612b73f231d0bf92
Comment 4 himajin100000 2019-09-21 22:03:22 UTC
probably confusion is coming from Excel's "Go To Special" dialog. 

https://www.excel-easy.com/basics/find-select.html#go-to-special

It looks as if checkbuttons are enabled only when Formulas radiobutton is selected and are disabled when Constants radiobutton is selected.

but in reality,
Checkbuttons are enabled even when EITHER Constants radiobutton OR Formulas radiobutton is selected.
Comment 5 QA Administrators 2021-09-21 04:52:40 UTC Comment hidden (obsolete)
Comment 6 Commit Notification 2022-09-06 09:32:41 UTC
Andreas Heinisch committed a patch related to this issue.
It has been pushed to "master":

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

tdf#118247 - Correctly handle xlCellTypeConstants parameter

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.
Comment 7 Andreas Heinisch 2022-09-06 09:35:55 UTC
This patch only resolves the correct handling of SpecialCells(xlCellTypeConstants, 1) and does not resolve the problems around multiple selection ranges of the ScVbaInterior object in the following code snippet:

Selection.SpecialCells(xlCellTypeConstants, 1).Select
With Selection.Interior
    .Pattern = xlSolid
    .Color = 5287936
End With
Comment 8 Andreas Heinisch 2022-09-06 09:36:28 UTC
and thx to himajin100000@gmail.com for the code pointers!