I am receiving the Error Message: Unexpected error while loading protected workbook: Sorry we couldn’t find r:\Office\3G36T\SystematicRiskManager v1.210.3.154.xlsm. Is it possible that it was moved, renamed or deleted? Please restart the protection program.
When I try to load a compiled save file via VBA.
I have a fairly complicated Excel application (c. 55k lines of code, c.30 worksheets, RTDs, forms and formulas etc). Because of this complexity, I have previously tried to implement saving selected sheets, ranges, cells with XLSPadlock, but it was not useable (18 months ago it crashed everytime so I gave up) and now is not feasible, as software updates may mean saved formulas, cells, ranges, names or even sheets may be moved or removed. For this reason, I am managing all loading and saving trough VBA, with inbuilt code to create my own data export/imports when a new version has been installed, but also saving the compiled file on every close.
On this basis, if the user is opening the same app version as last time, I want to automatically open the last compiled save file, created with the XLS Padlock VBA code:
Set XLSPadlock = Application.COMAddIns(“GXLS.GXLSPLock”).Object
strFilename = blah blah
XLSPadlock.SaveWorkbook strFilename
Which does work, and can be opened manually with the app, so I am quite confident the save file is not corrupted.
My issue, lies in the process of opening the save file via VBA.
I have simple code on open of the application, that confirms they are not using a newer version of the app, and if so the code to open the save file is executed:
Public Sub LoadXLSPadlockSaveFile(FilePath As String)
Dim XLSPadlock As Object
On Error GoTo Err
Set XLSPadlock = Application.COMAddIns(“GXLSForm.GXLSFormula”).Object
XLSPadlock.PLOpenSaveFile (FilePath) '<==Comment 1
ThisWorkbook.Saved = True '<==Comment 2
Application.Quit '<==Comment 3
Err:
End Sub
Comment 1: This line of code works. The application is loaded a second time, and starts to open app, but crashes before any VBA code is triggered (that I can tell)
Comment 2: I have added this, to try to force the close of the application that is loaded and trigerring the load of the save file (see Comment 3)
Comment 3: I am closing the first application, that is loaded and trigerring the load of the save file. There doesn’t seem to be any clear details, but I think there is a suggestion that you can’t have 2 instances of the app running in memory, BUT I have tried both with AND wothout calling the application.quit.
I can’t work out if I am doing something stupid, or missing the obvious, but if anyone can help it would be amazing. I hope this makes sense - 3 days into dealing with this means I’m starting to go crazy! Thank you very much in advance.