Archives

Honey, I Shrunk my Project File

I’ve mentioned in the past how difficult M2M’s flavor of VBA is to use. One problem that I haven’t touched on is the problem of VBA file corruption.

M2M VBA File Corruption? What exactly are you talking about?

When I talk about the VBA file, I am referring to the M2VEvents.prj file. This is the file which holds all of your VBA code including forms and modules. Every time you edit that file, it grows in size. There is no way that I know of to shrink it. If all of the modules are deleted, the file still doesn’t decrease in size.

Why should I care about how large the file is?

The problem is that over time these files can become corrupt and cause all sorts of weird behavior. This problem is very difficult to find because often the VBA customizations will not stop working all-together, but the code may work intermittently. The results are unpredictable.

Several years ago my current employer contracted with M2M to customize M2M using VBA and FastForms. I came on board in the middle of it. After M2M delivered the code file, I could not get it to work. Some modules would not work, and some would work, but not completely. When I opened the M2VEvents.prj file and reviewed the code, I knew that it should work. After nearly 40 hours of investigation, I realized that the file M2M had provided was corrupt. The consultant had to re-create a new file and the new copy worked. I’m sure they used the same method I am going to share with you.

Please read my standard disclaimer before you begin and perform these operations on a back up copy of your M2VEvents.prj file. Before beginning the process, note the size of the file.

What are the Steps?

  1. Open the VBPROJ screen to load the empty project. Easiest way is to hit ALT-F8.
  2. The currently used VBA Project File should be listed. Click edit and the VBA editor will open. Click the thumbnail below to see full size.
  3. Right click on each of your forms and modules and select Remove. You will be asked if you want to export them first, do so.
  4. After every form and module is removed you will find that your M2VEvents.prj file still has not shrunk. I have no idea why not. This is why you need to start with an “empty” one.
  5. Before proceeding, in the VBA window check your references. They’re found under Tools, References. Jot them down or take a screen shot. Click the thumbnail below to see full size.
  6. Download the attached “empty” M2VEvents.prj file.
  7. Go to your VBPROJ screen to load the empty project. The easiest way is to hit ALT-F8. Click on the Close button.
  8. Choose a screen which will have customizations associated with it. In this example, I did so with the SO screen. Right click on the mnemonic and choose Components.
  9. Select an event such as INIT and you’ll notice that the corresponding module has been created for you.
  10. Before importing any of the VB files, check your references in the new file. Once again, they’re found under Tools, References. Make sure that any that are included in your production system, are also included in the new prj file we are building.
  11. You may encounter a situation where your production prj file has a reference that is NOT found in the list of references for your blank file. If so, notice which file is referenced below and browse to it manually.
  12. Now import the frm and bas modules. However, you will have to remove the sample module created as your import will NOT replace it.
  13. Test your customizations just to be sure everything works.

I perform these shrinks every six months or so to avoid VBA file corruption. Note the difference in size of the file. My production file shrunk from 560KB to 131KB, roughly a 75% reduction.

So, how much did your file shrink?

Related posts:

8 comments to Honey, I Shrunk my Project File

  • I begged for a some “built in” way to customize M2M at the last user conf, to no avail. VBA has always been buggy, but it does work if you treat it with kid gloves. Make backups every 5 min.

    Has anyone had trouble getting it to work on Vista? ADO in particular.

  • I have done a lot of work with VBA. Whenever I am working on a Project I always copy each module code into a work document periodically for backup purposes. In the last three years I never remember a VBA script going corrupt or acting buggy without due cause on my programming.

    My method for knowing when I need to start from an empty project file is when my changes are not being saved in the Project once a leave M2M. Then I start with an empty project file and rebuild with the word documents.

    My biggest complaint with VBA is that the documentation on their set of tools is very vague. At the last user conference during a VBA session the VBA the presenter referred to an event that was new to me. I asked about the event and was told there are many events, methods and objects that do not even list out from M2M. You just have to know.

  • I’ve written many VBA scripts and in every case, I export the modules. It may be the only way you can recreate your hard work on the complex module, should it become corrupt.

  • scott

    I just shrank a prj file from 690kb to 236kb.

  • Paul Deleanu

    I just shrank a prj file from 1215 KB to 401 KB (67% reduction). Speaking of errors, users are sporadically getting “UPDATE CONFLICT IN CURSOR CBS_EA_TIMER” errors ever since we switched to M2M 6.0. Is anyone else getting these?

  • Paul, are you running Shop Floor Manager or Shop Floor Data Collection? I seem to remember having this problem some time ago. I’ll look into it and get back to you.

  • Paul Deleanu

    The only SFDC program we are running is Bar Code.

    These errors tend to occur only on certain screens (90% QUOTE and SO) and some users swear that if you go back two records and then forward again before editing the document you will never get the error.

    Rewriting the code for some screens (such as removing beforesave triggered code) has reduced the number of errors but has not eliminated them. One thing that seems to work is removing ALL VB code from the form, even though no code is running on save or edit.

  • D Minter

    I have been getting the “Update Conflict in Cursor” error intermittently when attempting to update contract pricing. Finally did a web search and found this post. I tried what Paul Deleanu mentions above – switched to a previous record and updated it first. This worked! Thank you very much. (Made2Manage version 5.6)

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>