Macro to Validate other Macros

P

Phil

I have some modules and macros in MSProject files that are distributed
to several client sites. Before they are run, I want to ensure that
they have not been modified, but I do want the clients to be able to
add their own modules and macros.

I am trying to write a macro that can check to see if
1) my module exists
2) if my module contains specific macros
3) if a checksum generated from the lines in those individual macros
match previously calculated values.

I cannot find an object to represent the module collection, the macro
collection, or the code in the macro, so I am not getting very far with
my code.

An alternate solution is to have the user export the modules to a text
file, using the Generic / Text Printer to File and then process the
result, but I would like to avoid that if possible.
 
J

Jan De Messemaeker

Hi all,

This calls for a little precision.
First, you cannot loop through a count, that is an integer.
More fundamentally, VBProjects contains the open VB Projects (interestingly,
the first one is the active Global.mpt, this is the way to address your
Global in VBA) not the modules.
These can be found in
VBE.VBProjects (1).VBComponents

The text of the code in the macro can be read through
VBE.VBProjects(1).VBComponents(7).Codemodule.Lines(1,7)

This generates the first seven lines of the code in the seventh module of
the Global.mpt project.

Hope this helps,
 

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