Making a function global

G

Guest

I have this function which I think that I found here. What I want to do is
make this function global so that it can be used in any workbook or
worksheet. So the question is how can I make this happen.

Function DocProps(prop As String)
Application.Volatile
On Error GoTo err_value
DocProps = ActiveWorkbook.BuiltinDocumentProperties _
(prop)
Exit Function
err_value:
DocProps = CVErr(xlErrValue)
End Function


TIA
GM
 
G

Guest

make it public and put it under the Modules folder

Public Function DocProps(prop As String)
Application.Volatile
On Error GoTo err_value
DocProps = ActiveWorkbook.BuiltinDocumentProperties _
(prop)
Exit Function
err_value:
DocProps = CVErr(xlErrValue)
End Function
 
G

Guest

To make a function accessable by any workbook the best place to put it is in
an addin. Your function causes a bit of a problem though if you send it to
anyone who does not have the addin. Application.volitile will force it to be
evaluated whenever a recalc is done and the function will return an error as
it will not be defined for them. The only effective way around that would be
to add the function within a module to each spreadsheet that you develope and
then the project will have to have a digital signature or the user will have
to enable macro's...
 
G

Guest

Jim,
Is there an easy way to install the function into each workbook with out
going to the VB editor? I would love to just have a macro that I could
trigger and it would put it into the workbook.

THannks
GM
 

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

Similar Threads


Top