[Solved] Does OO Calc Macros allow Private Sub Macros?
[Solved] Does OO Calc Macros allow Private Sub Macros?
There are times when I do not want the user to view or run Macros that I call from other subroutines. For example, when the order of running certain macros can damage your spread sheet. Does OO Support Private Subs? If so, How?
Last edited by alf50 on Mon Nov 26, 2012 12:17 am, edited 1 time in total.
OpenOffice 4.1.14 on Mac Catalina(10.15.7), RasPi4B (TwisterOS-8/2023update) & MS Wnds10
Re: Does OO Calc Macros allow Private Sub Macros?
I think:
The OOo Basic uses of the concept of Private SUB.
This means that the sub is only valid inside of the current Module.
The Modules can be hidden, but they everyone can display again.
The OOo Basic uses of the concept of Private SUB.
This means that the sub is only valid inside of the current Module.
The Modules can be hidden, but they everyone can display again.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
Re: Does OO Calc Macros allow Private Sub Macros?
i checked and can still see sub's (functions) that are private in the list of macros. how can i add this to the wish list?
above is a tests sub, when i open the macros dialog in the tools menu (Calc) I can see it.
What I would like is that a Sub marked private can be called by other functions in the same module but not appear in the run macros list
Code: Select all
Private Sub doInnerWork
MsgBox "do p"
End Sub
What I would like is that a Sub marked private can be called by other functions in the same module but not appear in the run macros list
OpenOffice 3.2.1 (9502) Win 7 SP2 http://sel2in.com
Re: Does OO Calc Macros allow Private Sub Macros?
Use Python which is mature, comprehensible, object oriented, easy to learn. It lets you define macro objects to be exposed.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
-
- Volunteer
- Posts: 1160
- Joined: Mon Oct 08, 2007 1:26 am
- Location: France, Paris area
Re: Does OO Calc Macros allow Private Sub Macros?
Hi,
But OpenOffice Basic uses the library concept. By default macros are stored in the library "Standard".
When the ordinary user opens the document he/she cannot see the content of the password protected library. Test yourself by reload of the document.
Warning
Basic Functions created for Calc formulas must reside in the Standard library. But from a Function in the Standard library you can load the protected library and call your secret function.
OpenOffice Basic ignores the Private term before a Sub. All Sub's are Public.tgkprog wrote:What I would like is that a Sub marked private can be called by other functions in the same module but not appear in the run macros list
But OpenOffice Basic uses the library concept. By default macros are stored in the library "Standard".
- Create a new library in the Basic Macro Organizer. Make sure you have chosen your document as Location.
- After creation you can specify a password.
- Put your secret macros in this library.
Code: Select all
BasicLibraries.loadLibrary("Library1") ' loading Library1
Warning
Basic Functions created for Calc formulas must reside in the Standard library. But from a Function in the Standard library you can load the protected library and call your secret function.
Bernard
OpenOffice.org 1.1.5 / Apache OpenOffice 4.1.1 / LibreOffice 5.0.5
MS-Windows 7 Home SP1
OpenOffice.org 1.1.5 / Apache OpenOffice 4.1.1 / LibreOffice 5.0.5
MS-Windows 7 Home SP1
Re: Does OO Calc Macros allow Private Sub Macros?
Tried this but it doesn't seem to be working: the password-protected library is accessible, as any other library.B Marcelly wrote:Hi,OpenOffice Basic ignores the Private term before a Sub. All Sub's are Public.tgkprog wrote:What I would like is that a Sub marked private can be called by other functions in the same module but not appear in the run macros list
But OpenOffice Basic uses the library concept. By default macros are stored in the library "Standard".You may call these macros from a macro in the Standard library, provided the protected library has previously be loaded.
- Create a new library in the Basic Macro Organizer. Make sure you have chosen your document as Location.
- After creation you can specify a password.
- Put your secret macros in this library.
When the ordinary user opens the document he/she cannot see the content of the password protected library. Test yourself by reload of the document.Code: Select all
BasicLibraries.loadLibrary("Library1") ' loading Library1
Warning
Basic Functions created for Calc formulas must reside in the Standard library. But from a Function in the Standard library you can load the protected library and call your secret function.
(developing a macro in Writer instead of Calc, I don't think the idea is different?)
LibreOffice 6.0.7.3 on Ubuntu 18.04.1
Re: [Solved] Does OO Calc Macros allow Private Sub Macros?
You could put the subs in a module called InternalUseOnly or something else that discourages the user from looking there.
And stop the macro doing anything if its run from a menu as a parameter won't be provided:
Edit:
Another roundabout approach would be to customise the Tools menu with your own replacement or supplementary "Macros" button that loads your own dialog or menu with just the macros you want the user to be able to run. The normal macros run dialog is VERY clunky anyway... you've got to find the library... then the module... then the sub... terrible...
And stop the macro doing anything if its run from a menu as a parameter won't be provided:
Code: Select all
Sub test(optional key)
if ismissing(key) =true then exit sub
msgbox 4
End Sub
Another roundabout approach would be to customise the Tools menu with your own replacement or supplementary "Macros" button that loads your own dialog or menu with just the macros you want the user to be able to run. The normal macros run dialog is VERY clunky anyway... you've got to find the library... then the module... then the sub... terrible...
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)