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...
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
(earliest affected) release
Hardware: All All
: medium normal
Assignee: Andreas Heinisch
Whiteboard: target:7.5.0
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:
Regression By:

Example file from Excel (25.70 KB, application/vnd.ms-excel.sheet.macroEnabled.12)
2018-06-19 16:37 UTC, Gabor Kelemen (allotropia)
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)

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
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.

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

Arch Linux 64-bit
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
Build ID: b7cfa1eab1cb1e94f71d6df6612b73f231d0bf92
Comment 4 himajin100000 2019-09-21 22:03:22 UTC
probably confusion is coming from Excel's "Go To Special" dialog. 


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":


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:

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!