Functions - visibility

L

Ludo

Hi,

Functions within a project (.xls, .xlmx, .xla,.xlax) are verry
usefull, but i have a question abouth the 'visibility' of the
functions.

I know that if a function is declared as Private, it's 'invisible'
outside the project, but once you declare it as Public, it's also
visible outside your project and can be seen in the Excel Functions
dropdown box.

My 'problem' is following.
I'm writing a add-in with multiple UserForms and multiple Modules. I
have several function in this project, and some of them are 'called'
from different modules / userforms. Obvious, i need to declare them as
Public, so that i can use this (those) functions(s) from the different
modules / userforms. This means also that this (those) functions are
visible outside the project. This can be dangerous if someone use this
function outside the project. Is there a way to call a function from
different userforms / modules within the same project, but make them
invisible to the 'outside world'?

Regards,
Ludo
 
G

GS

Ludo laid this down on his screen :
Hi,

Functions within a project (.xls, .xlmx, .xla,.xlax) are verry
usefull, but i have a question abouth the 'visibility' of the
functions.

I know that if a function is declared as Private, it's 'invisible'
outside the project, but once you declare it as Public, it's also
visible outside your project and can be seen in the Excel Functions
dropdown box.

My 'problem' is following.
I'm writing a add-in with multiple UserForms and multiple Modules. I
have several function in this project, and some of them are 'called'
from different modules / userforms. Obvious, i need to declare them as
Public, so that i can use this (those) functions(s) from the different
modules / userforms. This means also that this (those) functions are
visible outside the project. This can be dangerous if someone use this
function outside the project. Is there a way to call a function from
different userforms / modules within the same project, but make them
invisible to the 'outside world'?

Regards,
Ludo

You could put the following statement at the top of each module in
your project...

Option Explicit '//you should already have this
Option Private Module '//make code available to 'this' project only

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
 
L

Ludo

Ludo laid this down on his screen :
Hi,

Functions within a project (.xls, .xlmx, .xla,.xlax) are verry
usefull, but i have a question abouth the 'visibility' of the
functions.

I know that if a function is declared as Private, it's 'invisible'
outside the project, but once you declare it as Public, it's also
visible outside your project and can be seen in the Excel Functions
dropdown box.

My 'problem' is following.
I'm writing a add-in with multiple UserForms and multiple Modules. I
have several function in this project, and some of them are 'called'
from different modules / userforms. Obvious, i need to declare them as
Public, so that i can use this (those) functions(s) from the different
modules / userforms. This means also that this (those) functions are
visible outside the project. This can be dangerous if someone use this
function outside the project. Is there a way to call a function from
different userforms / modules within the same project, but make them
invisible to the 'outside world'?

Regards,
Ludo

You could put the following statement at the top of each module in
your project...

Option Explicit '//you should already have this
Option Private Module '//make code available to 'this' project only

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


Thanks a lot Garry for the response.
The 'Option Explicit' is always on, wasn't aware of the 'Option Private Module'.

Regards,
Ludo
 
G

GS

Ludo pretended :
Ludo laid this down on his screen :
Hi,

Functions within a project (.xls, .xlmx, .xla,.xlax) are verry
usefull, but i have a question abouth the 'visibility' of the
functions.

I know that if a function is declared as Private, it's 'invisible'
outside the project, but once you declare it as Public, it's also
visible outside your project and can be seen in the Excel Functions
dropdown box.

My 'problem' is following.
I'm writing a add-in with multiple UserForms and multiple Modules. I
have several function in this project, and some of them are 'called'
from different modules / userforms. Obvious, i need to declare them as
Public, so that i can use this (those) functions(s) from the different
modules / userforms. This means also that this (those) functions are
visible outside the project. This can be dangerous if someone use this
function outside the project. Is there a way to call a function from
different userforms / modules within the same project, but make them
invisible to the 'outside world'?

Regards,
Ludo

You could put the following statement at the top of each module in
your project...

Option Explicit '//you should already have this
Option Private Module '//make code available to 'this' project only

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


Thanks a lot Garry for the response.
The 'Option Explicit' is always on, wasn't aware of the 'Option Private
Module'.

Regards,
Ludo


Glad to help! Best regards...

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top