Having problems with copying macros

S

Steph

Hi -

Having an issue with macros - hopefully someone has some brilliant ideas:

1)Need to update a set of macros for all our users. Each user has a separate
global.mpt on their PCs (wish we could do one global.mpt on the server, then
I wouldn't need to ask this question - but we can't.)

2) Wrote some code - on Project_Open - to check if the macros are the
correct version. If not - it opens another .mpp file that contain the new
macros, and then copies the new macros to the user's global.mpt. However,
the problem I'm running into, is that one of the modules is in use, and the
new version gets copied and renames the module - adding a "1" to the name.

3) The module that is in use is simply a list of constants called mVersions:
Public Const vers = "Version 3.02"
Public Const vdate = "December 9 2004"
Public Const pver As Integer = 301
Public Const currsvr = "c:\documents and settings\my documents\"
Public YesACRun As Boolean

4) After the code runs to update the macros - this module gets renamed to
mVersions1. Which isn't so bad. However, if I run the update macro again,
mVersions gets added again - and now there are two - mVersions1, and
mVersions - which is bad.

So - my questions are - how can I avoid mVersions getting renamed to
mVersions1? or - how can I rename it back to mVersions? Or is there a better
process I should be using in the first place?

TIA

Stephanie
 
W

WD

Steph --

If I was going to do what you are doing I would take the following approach:

you would have to disable macros (not allow them to load) to avoid the
in-use issue
Check for the correct version
if correct do nothing
if not correct delete incorrect version (organizerdeleteitem)
copy correct version (organizermoveitem)

this would end the 1 being appended to your macro name
 
S

Steph

Wd - thanks for your reply - but I can't disable macros - at least not in
the global.mpt - I am running a macro from the global.mpt to copy macros
from another file into the global.mpt.
 
W

WD

Steph --

You will more than likely have to develop a routine for the OnClose event to
traverse through the macro names in a similar sequence:

1. Does any macro have a 1 at the end of the name (right(name,1)) = 1
2. If true then you would want to compare all name upto the 1 with the other
macros and delete the one that matches and rename the macro with the 1.

During the Open event, I would capture all of the macros that need to be
updated into a public array. Then I would use that public array in my OnClose
event to compare and determine which macro was not renamed; or was appended
with a 1. Then I would take action from there.
 

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