Bug 131563 - Cannot set cell font color from VBA macro
Summary: Cannot set cell font color from VBA macro
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Andreas Heinisch
URL:
Whiteboard: target:7.3.0 target:7.2.3
Keywords:
Depends on:
Blocks: Macro-VBA
  Show dependency treegraph
 
Reported: 2020-03-25 11:46 UTC by NISZ LibreOffice Team
Modified: 2021-10-25 11:11 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:
Regression By:


Attachments
Example file from Excel (12.16 KB, application/vnd.ms-excel.sheet.macroEnabled.12)
2020-03-25 11:46 UTC, NISZ LibreOffice Team
Details
Screenshot of the original document side by side in Excel and Calc after running the macro (71.60 KB, image/png)
2020-03-25 11:46 UTC, NISZ LibreOffice Team
Details

Note You need to log in before you can comment on or make changes to this bug.
Description NISZ LibreOffice Team 2020-03-25 11:46:21 UTC
Created attachment 158975 [details]
Example file from Excel

Attached file contains a simple macro to set cell borders.
This call does not work in Calc:

Cells(2, 1).Font.Color = vbRed

Steps to reproduce:
1.	Open attached xlsm file
2.	Run the macro in Excel and Calc

Actual results:
A2 cell text becomes red in Excel but stays default in Calc.

Expected results:
A2 cell text becomes red in Calc.

LibreOffice details:
Version: 7.0.0.0.alpha0+ (x64)
Build ID: bc898e2c2784e36ad4d4cdf6d962e39069d2c82d
CPU threads: 4; OS: Windows 6.3 Build 9600; UI render: Skia/Raster; VCL: win; 
Locale: hu-HU (hu_HU); UI-Language: en-US
Calc: CL

Also happens in
LibreOffice 3.5.0rc3 
Build ID: 7e68ba2-a744ebf-1f241b7-c506db1-7d53735
Comment 1 NISZ LibreOffice Team 2020-03-25 11:46:39 UTC
Created attachment 158976 [details]
Screenshot of the original document side by side in Excel and Calc after running the macro
Comment 2 himajin100000 2020-03-25 14:59:09 UTC
Rem Attribute VBA_ModuleType=VBADocumentModule
Option Explicit
Option VBASupport 1

Sub FontColor()

Cells(2, 1) = "Hello World"
Cells(2, 1).Font.Color= &H00FF

End Sub


vbRed not defined?
Comment 4 Xisco Faulí 2020-03-25 15:58:51 UTC
Reproduced in

Version: 7.0.0.0.alpha0+
Build ID: 9163755e9f64a0b1dd5f2090e0702c19e31c12c9
CPU threads: 4; OS: Linux 4.19; UI render: default; VCL: gtk3; 
Locale: en-US (en_US.UTF-8); UI-Language: en-US
Calc: threaded
Comment 5 himajin100000 2020-03-26 17:09:01 UTC
forgot to mention another source of constants and enums( but this is not so related to this bug itself. It's just FYI)
https://opengrok.libreoffice.org/xref/core/basic/source/runtime/stdobj.cxx?r=62f3f3d9#332
Comment 6 Commit Notification 2021-09-27 13:32:40 UTC
Andreas Heinisch committed a patch related to this issue.
It has been pushed to "master":

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

tdf#131563 - Add vba color constants

It will be available in 7.3.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 2021-09-27 13:33:30 UTC
Thx himajin for the code pointer!
Comment 8 Commit Notification 2021-09-28 09:01:03 UTC
Andreas Heinisch committed a patch related to this issue.
It has been pushed to "libreoffice-7-2":

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

tdf#131563 - Add vba color constants

It will be available in 7.2.3.

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 Commit Notification 2021-10-25 11:11:51 UTC
Alain Romedenne committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/help/commit/cae1ccb6137d03cada0e187756e9197a897ba94b

tdf#131563 VBA color constants