Using Modules in Multiple Files

  • Thread starter Michael Suttkus, II
  • Start date
M

Michael Suttkus, II

I have certain modules which contain functions and procedures I want to use
in several different projects. Obviously, I could cut and paste, or even
export and import, but these solutions are inefficient and lead to a hassle
when it comes time to update the files. (i.e., if I make a change to one of
the modules, I have to open up every other file where it is being used and
import the new text. Yeesh!)

Short of getting the administrators to let me have access to Studio and
program my own dlls, is there any effective way to simply this?
 
C

Chip Pearson

Unfortunately, there is no such thing similar to a C #include
statement. You have to maintain the module in each project
separately.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
T

TC

OP, spend 30 minutes writing your own "include" pre-processor in any
convenient language!

HTH,
TC
 
T

Tony Jollans

This will depend on what application you are using and how you want to use
the procedures and some other factors but, in general, if you have a
container (a Word global template or an Excel personal.xls or equivalent)
holding all your code you should be able to set references to it in other
projects and use the procedures as though they were in your project.
 
T

TC

But the OP is talking of physical inclusion AFAICS.

Some time ago, being new to HTML, I went crazy trying to find out how
to include one HTML file within another. I tried various methods, none
of which seemed to work correctly in all cases. Then the lightbulb went
on, and I just wrote my own pre-processor in a few lines of VBA. The
VBA reads the nominated input files, checks for "include" directives of
my own design, & produces the necesary output files, which incorporate
all of the requested inclusions.

Maybe the OP can do something similar.

Cheers,
TC
 
S

Steve Rindsberg

But the OP is talking of physical inclusion AFAICS.

Some time ago, being new to HTML, I went crazy trying to find out how
to include one HTML file within another. I tried various methods, none
of which seemed to work correctly in all cases. Then the lightbulb went
on, and I just wrote my own pre-processor in a few lines of VBA. The
VBA reads the nominated input files, checks for "include" directives of
my own design, & produces the necesary output files, which incorporate
all of the requested inclusions.

That works for text files on a one-shot basis. Bit trickier but perhaps by
means of comments or the like, you could mark the beginning and end of the
insertion so it can be updated later.

No help if you have a compiled app that uses a set of routines that might need
updating, possibly even on a remote machine.

I don't know how XL and Word handle this but in PPT, one add-in or macros in a
presentation can call functions/subs from another add-in, so it's fairly easy
to do this.
 
T

TC

Steve Rindsberg wrote:

That works for text files on a one-shot basis. Bit trickier but perhaps by
means of comments or the like, you could mark the beginning and end of the
insertion so it can be updated later.

You don't ever update the included text directly. You update the
original(s) & then re-run the preprocessor :)

No help if you have a compiled app that uses a set of routines that might need
updating, possibly even on a remote machine.

Not sure what you're getting at there. The mechanism I suggest is just
a way of implementing a local Include facility where none existed
before. What you then do, or can't do, with the output files, is
another matter, IMHO.

Cheers,
TC
 
T

Tony Jollans

I really think HTML is slightly different - the options available, and the
environment, are different. If you're happy to use JavaScript you can
effectively include other HTML. Anyway ...

The OP wanted to *use* common procedures. Having a single copy available
seems to satisfy that requirement and what I proposed also addresses the
issue of hassle and inefficiency. It may or may not suit - we'll have to
wait and see.
 
S

Steve Rindsberg

Not sure what you're getting at there.

The original problem as posed by the OP? ;-)

In effect, the problem is "How do you get the functionality of DLLs - which allow
you to share a common and easily udpated code base across multiple apps - w/o
having to make DLLs?"

I don't think an include processor gets you there.

Not to say that they're not hugely useful. Every page of HTML on my site is the
result of include processing such as you describe.


The mechanism I suggest is just
 
T

TC

Steve Rindsberg wrote:

In effect, the problem is "How do you get the functionality of DLLs - which allow
you to share a common and easily udpated code base across multiple apps - w/o
having to make DLLs?"

I don't think an include processor gets you there.


I disagree! You are pre-supposing the OP's implementation mechanism.
The OP said:
I have certain modules which contain functions and procedures I want
to use in several different projects. Obviously, I could cut and paste,
or even export and import, but these solutions are inefficient and lead
to a hassle when it comes time to update the files. (i.e., if I make a
change to one of the modules, I have to open up every other file where
it is being used and import the new text. Yeesh!

IMO there is no clear evidence that he wants to create DLLs. He just
wants to be able to share common code across multiple projects. Include
files could easily do that.

Cheers! :)
TC
 
T

TC

Oops, he also said:
Short of getting the administrators to let me have access to Studio and
program my own dlls, is there any effective way to simply this?

IOW he explicitly does not want to use DLLs if he can avoid it.

Cheers,
TC
 
S

Steve Rindsberg

I disagree! You are pre-supposing the OP's implementation mechanism.
The OP said:


IMO there is no clear evidence that he wants to create DLLs.

But I *did* say "without having to make DLLs". See quote above.
wants to be able to share common code across multiple projects. Include
files could easily do that.

It depends on the level OP wants to work at. If recompiling ALL the apps/addins
every time a change is made to one of the include files is ok, then include files are
ok.

Incorporating an add-in by reference sidesteps that need.

But we've had our say, I think we agree that there are differnt tools for different
jobs; OP can decide what the job really IS and what tools to whack it with. ;-)
 

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