Wayne,
This has been the behavior of SolidWorks macros for years. Whenever a User runs a macro, that macro remains open in SolidWorks memory (kind of like opening an assembly file, and even tho you only opened that one file you actually have ownership of all of the component files [and they're open] in the background). Below is the macro behavior I've observerd, and the method I use to make and distribute macro updates for macros shared across a network.
During an SW secession, run a few macros and then go into the Macro Editor. You will *all* the macros you've run listed in the Project Window. Go up to the Run menu and choose 'Reset'. Now close the Editor, then go back into the editor (you'll have to choose a macro to edit, choose any one that you want). Now in the Macro Editor you will only see that one macro listed in the Project Window. Hence you have released ownership of all the other macro files (or at maybe better stated...closed all the macros SW had open in the background). So during a SolidWorks secession, if you never go into the Macro Editor and hit the 'Reset' button, which I would *not* expect Users to do (and they shouldn't have to), then that macro (and *all* others) will remain open in their SolidWorks secession until they close SolidWorks. In the macro code itself, I have tried clearing out all variables and objects at the end of the macro, but no matter what I tried...that macro remains in SW memory until I either 'Reset' in the Macro Editor, or close SW. The only advantage I've seen from this behavior is that macros already open in the SW background do initialze/load faster (maybe a couple tenth's of a second faster but for the most part hardly even noticable unless you are paying attention and comparing). Try it for yourself, it is noticable even without a stopwatch. :o)
To continue, so what happens is that the first User to run the macro gets Write-Access to the file. Any subsequent users that run the macro get Read-Only Access. Note that if the owning User changes that macro code and saves the changes, none of the Users that have the macro open Read-Only will see the changes until they either 'Reset' or restart SW (because they still have the Read-Only version open in the background and will continuse using that version until it gets dumped from memory). Also, once the owning User has hit Save in the Macro Editor and closes that macro, SW releases ownership the macro (and the macro will *not* be open in your SW secession any more, same as hitting 'Reset'). The next user to run that macro that does not already have the Read-Only version open, will then get ownership (i.e. Write- Access) of that file.
The work-around I use for editing/updating macros shared across a network is:
1) Make a "User Macros" directory (for instqance the one you're Users are all already looking at), and make all macros in that directory Read-Only from Windows Explorer. Even better would be to store that directory in a location that only Administrators have write-access rights too.
2) Copy that folder and all the macros to a different location on the network. Remove the Read-Only setting on the files. Consider this your
*Master Macros* file location. Put this somewhere that only you (or Administrators) have access to. This is were you will edit macros, and even run macros from when debugging. Do not consider this a production usage location for macros. Personally, I always make a backup copy first so I don't have to bother the IT guys if I screw the macro up and want to restore it and start over.
3) Now what happens is that all Users will run macros from the "User Macros" location and will get Read-Only access to the files when running them, therefore the files will not be locked. What you will do is Edit a macro from the "Master Macros" directory, and once you're happy with it copy it over the file in the "User Macros" directory. a) If a User is in an urgent need of this update, tell them to close down and re-start SolidWorks (which is easier than explaining the whole 'Reset' thing in the Macro Editor, but doing the 'Reset' thing will allow them to keep SW and any files open and running, so your choice). Otherwise (if it's not urgent to distribute the update), you know that the macro file is updated, and that the next time they re-start SW they will see the update (this is what I usually do). b) You may be wondering why I don't just store the "User Macros" in an location with Admin Rights only and just edit the macros there (since I'm the only SW User with Admin Rights)...I tried this, but it seemed inconsistent in saving my changes. Even tho other Users had the file open Read-Only, I still had times where the Macro Editor did not save my changes. I know this sounds like a User (i.e. myself) error, but editing the macros there and getting them to save was not reliable for me. Editing the macros in a separate (Master) directory meant that my changes were
*always* saved. Even if some how an error happened when trying to copy the Master Macro over the User Macro, I know that the Master Macro is right
*and more importantly* I don't loose my changes.
Later, Ken
Make a "User Macros" directory (like the one you're Users are all already looking at), and make all macros in that directory Read-Only from Windows Explorer.