11 Replies Latest reply on Dec 7, 2016 2:31 PM by Blakely Watson

    VBA Editor isn't saving my work

    Tim Lewis

      Less than a week ago, I posted this explaining my frustration with the VBA editor corrupting my SWP files.  Now, it's not saving my file at all.

       

      I have the attached SWP file and want to change the "HelperMacros" module to include the modifications included in the attached BAS file (which are basically just modifying the last function in the module slightly).  In order to accomplish this, I remove the existing "HelperMacros" module, import the BAS file, and save the SWP file (using either Ctrl-S or the "Save" button).  The macro will then work fine as long as I have the VBA editor open, but once I close the editor, it reverts to the old behavior.  Opening the SWP file back up in the editor shows that nothing has changed.  This is especially strange since the timestamp on the SWP file seems to be getting updated (at least in this case) when I save the file.

        • Re: VBA Editor isn't saving my work
          Scott Stuart

          This is most likely a permissions problem. This happens to me when I'm trying to edit a macro that's on a network share and another user has run the macro in their current session of SolidWorks. The other person doesn't have to have it open for edit, just having run it once in their current session locks it and prevents you from being able to save, and SW and/or the VBE is not smart enough to tell you the save failed. If that is the case, you need to (get your IT guy to) log into the server and "close open file" on that file to boot the other person out of it. That, or make other users close their SolidWorks, which will also release the lock.

            • Re: VBA Editor isn't saving my work
              Tim Lewis

              That may well be right.  The file is saved on our server.  However, I'm the one that created the file, and I'm the only one that uses it.  I checked the permissions on the file from Windows Explorer, but they showed that I have full permissions on the file.  Are there any other things I could try to try to track down the source of the problem?

                • Re: VBA Editor isn't saving my work
                  John Alexander

                  Is it possible that a coworker stumbled across it and tried running it? If so, even without launching the VBA editor, they could be blocking changes if it is still loaded. I'm not sure what the mechanism is that causes the blocking but have observed it often enough with my group that I will maintain a released version on the network and a development version on my local drive.

                  • Re: VBA Editor isn't saving my work
                    Scott Stuart

                    Try saving a copy locally, then deleting the file off the server. If you can't delete it, then you need to get IT to force it closed. If you can delete, then save the copy back to the original location and see if you can edit.

                      • Re: VBA Editor isn't saving my work
                        Tim Lewis

                        Well, I left SolidWorks open over night, and when I came back in and saw your suggestion, I closed the files I was working on and shut it down.  When I closed the VBE, I got the message asking if I would like to save the changes I had made to the macro that was open.  This is normally a good sign since that is typically more reliable than using the "Save" button or Ctrl-S.  However, when I tried to open the macro again, this is basically what happened (all except for the first message box, and there is no "+" beside the empty projects in the Project Explorer).  Basically, SolidWorks corrupted my file (again).

                         

                        Oh, and by the way, when I tried deleting the file from the server after closing SolidWorks, it was successfully deleted, so as I thought, no one else was using the file.

                         

                        To say the least, I think it should be obvious at this point how frustrating this is.  At various times, I frequently have problems with VBE either not saving the macro or saving a corrupted file.  Why can't everything just be stored in plain text?

                  • Re: VBA Editor isn't saving my work
                    Blakely Watson

                    I recently had the same problem. What I found was that there would be 2 versions of SolidWorks running somehow (2nd one may have opened automatically when editing the macro). Click "Ctrl+Alt+Del" and see if more than 1 of SLDWORKS.exe is running. Delete all of them and restart SolidWorks and edit the macro. It should now save the changes. This is how I fixed my problem. I hope this works for you as well.