Link between 2 files does not work since version 3.0


#1

Hello,

I am using XLS Padlock to protect one of 2 Excel files that are linked. The principle is the following :

  • the main file contains a lot of vba code that we want to protect and is compiled thanks to XLS Padlock

  • the second one is a kind of big form. The user use it to enter their data and there are Activex control wich are linked to the main file through the following code :

           fichier_source = ThisWorkbook.Name (name of the second file)
           Chemin = ThisWorkbook.Path  (path ot the second file)
           Application.Run "MainFile.xlsm!Macro_name.Button_name", fichier_source, Chemin
    

It used to function very well but it has stopped with version 3.0. I have tried all the following versions of XLS Padlock and none of them allow this system to work. Is there a way to make it work again ? I am still using the version 2.5 of XLS Padlock but I would like to upgrade to the latest one.

Thank you !


#2

The error message I get is :

         Execution error '1004' : 
         Sorry... We do not find Path.Mainfile.xlsm. 

It seems as if the main file is invisible. When I open the developer tab thanks to the “debug” button I cannot see my main file, which used to be the case with previous versions of XLS Padlock.


#3

Our user guide has the solution to your problem:

We also recommend you to upgrade to the last version, because Excel is constantly being upgraded by Microsoft nowadays.


#4

Hello,

thank you very much for your answer. I thought at first that it was the solution but it does not seem to be the case.

Indeed, I don’t have any problem with “ThisWorkbook.Path” since “ThisWorkbook” is the second file, wich is not protected.

The issue is in the following line :
Application.Run “MainFile.xlsm!Macro_name.Button_name”, fichier_source, Chemin

MainFile.xlsm can’t be found by the second file. I have created the public function “PathToFile” but I don’t understand how it works and how I can use it. I have tried to replace MainFile.xlsm by PathToFile(“MainFile.xlsm”) but it doesn’t work.

Could you help me ?


#5

Either add your MainFile.xlsm as a Companion file (search for Companion in our user guide) or make sure that the protected workbook opens the MainFile.xlsm in the secure instance (use VBA to open this workbook and PathToFile so that Excel can find it). Otherwise it can only fail.


#6

Hello,

I am not sure that I understand your previous message. MainFile.xlsm is the protected workbook, the other one is a non protected workbook. The code contained in MainFile.xlsm is called by the non protected workbook (both are opened manually by the user).

I have tried to add the second workboork as a companion file for MainFile.xlsm but it doesn’t work.

I think that PathToFile is the solution but I do not manage to understand how it works. Since the second file cannot find “MainFile.xlsm”, I have tried to create the function then to replace MainFile.xlsm by PathToFile(“MainFile.xlsm”) but it doesn’t work.


#7

Use VBA to open the 2nd workbook in the same folder as the EXE.

Public Function PathToFile(Filename As String) 
Dim XLSPadlock As Object 
On Error GoTo Err 
Set XLSPadlock = Application.COMAddIns("GXLSForm.GXLSFormula").Object 
PathToFile = XLSPadlock.PLEvalVar("EXEPath") & Filename 
Exit Function 
Err: 
PathToFile = "" 
End Function 

And in your code before running the macro:

 Workbooks.Open Filename:= PathToFile("data.xls")