Download it now!
Bug 35596 - Cannot name macro "Green()"
Summary: Cannot name macro "Green()"
Status: RESOLVED WORKSFORME
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
3.3.0 release
Hardware: Other All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Macro-VBA Macro-StarBasic
  Show dependency treegraph
 
Reported: 2011-03-23 09:24 UTC by jkonecny
Modified: 2019-11-22 08:59 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description jkonecny 2011-03-23 09:24:14 UTC
Strange unless I am doing something wrong...  When Application.Run calls "Green" I get an error "macro does not exist.  If I name it anything other than Green (including other color names) it works ok.  It also works if I call it by running...

Application.Run Green instead of Application.Run "Green".

REM - Does not work
Option VBASupport 1
Sub Green()
  msgbox "You called the Green macro!"
End Sub

Sub test()
   Application.Run "Green"
End Sub

REM - Works
Option VBASupport 1
Sub Green()
  msgbox "You called the Green macro!"
End Sub

Sub test()
   Application.Run Green
End Sub

REM - Works
Option VBASupport 1
Sub Greenx()
  msgbox "You called the Green macro!"
End Sub

Sub test()
   Application.Run "Greenx"
End Sub
Comment 1 Katarina Behrens 2011-03-24 06:43:15 UTC
Noel, please have a look, I'm not sure if this is bug or feature
Comment 2 Noel Power 2011-03-24 08:03:31 UTC
I'll take a look, sounds weird, I would nearly bet there is some RTL 'Green' function that is causing confusion
Comment 3 Regina Henschel 2011-03-24 15:26:29 UTC
Green, Red and Blue are build-in Basic functions, see alphabetic list in the help.
Comment 4 jkonecny 2011-03-24 17:03:35 UTC
Well that would make the VBA macros incompatible with excel I believe.  This came in from an excel sheet where it worked.
Comment 5 August Sodora 2012-01-08 11:00:53 UTC
Is there a way to restore VBA compatibility without breaking applications that use Red/Green/Blue from the basic runtime? Perhaps detecting Option VBASupport 1 is enough?

Also shouldn't the error message be something more like "Macro already exists" than "Macro does not exist"?
Comment 6 Noel Power 2012-01-09 04:14:54 UTC
(In reply to comment #5)
> Is there a way to restore VBA compatibility without breaking applications that
> use Red/Green/Blue from the basic runtime? Perhaps detecting Option VBASupport
> 1 is enough?
> 

there is and I thought that I fixed this issue previously ( or at least the rtl function visibility part ) :-/ There was previously a flag that could be set to flag mark an RTL function to be only available in compatibility mode, I extended that to also be able to set a flag to mark a function only available in 'libreoffice' basic mode. ( see. _COMPTMASK, _COMPATONLY & _NORMONLY ) in basic/source/runtime/stdobj.cxx )

however it seems this does not work as expected at the moment, the behaviour currently is that a function deemed to be available in compatibility mode is indeed not available until 'Option VBASupport 1' is set, however once that option is enabled the function is available forever more ( until the office is restarted ). Similarly a function that is specified as unavailable in compatibility mode will be unavailable as long as 'Option VBASupport 1' is specified, but... after the first time the function is called in non-compatibility mode then the function will always be found.

It seems that in openoffice the previous incarnation ( e.g. setting a function to be available in compat mode only ) also exhibits the same problem. Its not clear whether this was always the behaviour or not ( clearly it's not desirable ) Not even sure what the correct 

> Also shouldn't the error message be something more like "Macro already exists"
> than "Macro does not exist"?

one might say that probably should be a compile time error, but I doubt that the basic compiler is smart enough to realise this as it resolves nearly everything at runtime.

Note: there seems to be an additional problem here in that 

Application.Run "Green" will not resolve, the current implementation expects at least the Module to be specified ( note: in a standalone example e.g not an imported document you would need to specify the complete location  Application.Run "Standard.Module1.Green" as the project name is not correctly set up )
Comment 7 QA Administrators 2014-06-25 17:37:58 UTC Comment hidden (obsolete)
Comment 8 QA Administrators 2015-07-18 17:44:16 UTC Comment hidden (obsolete)
Comment 9 Xisco Faulí 2016-09-10 16:04:40 UTC
Hi Noel,
I'm setting this ticket back to NEW as it has been inactive for more than 3
months.
Feel free to assign it back to you if you're still working on this.
Regards
Comment 10 Xisco Faulí 2017-09-29 08:52:46 UTC Comment hidden (obsolete)
Comment 11 Buovjaga 2019-08-10 16:46:43 UTC
(In reply to jkonecny from comment #0)
> REM - Does not work
> Option VBASupport 1
> Sub Green()
>   msgbox "You called the Green macro!"
> End Sub
> 
> Sub test()
>    Application.Run "Green"
> End Sub

This works for me on Linux.

If someone can still reproduce, set back to NEW

Arch Linux 64-bit
Version: 6.4.0.0.alpha0+
Build ID: 37fc9f51a8de11d40632e8cda17ccf1fa4b1f503
CPU threads: 8; OS: Linux 5.2; UI render: default; VCL: gtk3; 
Locale: fi-FI (fi_FI.UTF-8); UI-Language: en-US
Calc: threaded
Built on 6 August 2019