Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling function residing in another project (MS-Word) 2

Status
Not open for further replies.

GBressinck

Technical User
Aug 7, 2003
4
BE
Does anyone know how to call a function that resides in another project ?

I have a set of utility function that I want to use in different projects, therefore I created a file utils.dot that word loads automatically at startup.

Now I want to create a new project MyProject, in which I have a module MyModule with function MyFunc() that should make use of a function in the Utils project (e.g. the project Utils has a module ProcesUti in which a function GetProcessId resides).

How can I call the function GetProcessId from within MyFunc?

 
I know this is not the answer you want, but...
I'd avoid the hassle and keep the utility functions all in one module, then just copy the module to into any project that needs them. Otherwise, even if there is a way to call on an external function (I don't recall if there is), undoubtedly the syntax is more complex, and you risk somewhere down the line losing access when for whatever reason utils.dot gets closed.


Rob
[flowerface]
 
Thx for the answer although it is not what I wanted to hear.

The reason I would put it in a project is that this represents one file; this would allow me to have some kind of version control and maintainability for the functions: e.g. I could update my utils project (library) without having to update all my other projects (applications) that rely on this library. All apllications would automatically share the same base functionality offered by my library.

Thats why I grouped all these functions into logical blocks (modules in vba) and grouped those blocks into projects.



 
Hi GBressinck,

I don't understand the problem If your template is open you can invoke a function within it the same way you invoke any other function. Scope is not limited to a particular project.

Various packages install things this way and there shouldn't be a significant danger of accidently losing access.

Enjoy,
Tony
 
Tony,

That is what I thought to be the case.
However when trying to do it, I get a runtime error from vba and it tells me 'Compile Error: function or sub not defined'.

When writing the code, the function name is recognized however (i.e. capitalization does take place when typing in the name of the function)
 
I run into the same problem. In Excel VBA, functions defined in ANY project are available as custom worksheet functions, but they are not available to VBA in other workbooks' projects. Same for Word VBA - not even functions in normal.dot are in scope for other projects.


Rob
[flowerface]
 
Hi GBressinck, Rob,

You threw me a bit when you said you couldn't do it until I remembered that, like anything else, in order to use your project/template you must have a reference to it.

If you set up a reference in your global template (normal.dot) to your utils.dot you should be able to use it as you wish.

Enjoy,
Tony
 
By golly you're right! I never knew that you could use a .xls as a reference. Cool!


Rob
[flowerface]
 
Thx guys, it really is the reference thing that does the trick.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top