Add Companion Files

 

All XLS Padlock Options > Application Settings > Add Companion Files

 

Your workbook can be linked to other workbooks or data sources. To preserve links, you can specify additional workbooks or other files that will be compiled inside the application EXE. They will be made available in the same virtual folder as the main workbook automatically. It is even possible to include XLL add-ins.

 

For instance, you have a workbook with a data source available as an external text file. You can add the text file as a Companion file, so that Excel will be able to find the external text file when the compiled workbook is opened. This ensures that companion files are always available on other computers.

To add one or more files, click Add Files and select them. They are added to the list.

The Storage Filename column tells you with which filename they will be compiled inside the application EXE file and restored at runtime.

Do not add very large files because they will be stored in memory. If you would like to link to other workbooks or large data files, you can leave them in the same folder as the application EXE file and use references to these files. References can be set up with the XLS Padlock built-in Excel function named PLEvalVar("XLSPath"). Please refer to the section: Use external references and hyperlinks.

 

If you want to access companion files with VBA code, you can use the following VBA code snippet (copy and paste it into a module):

Public Function PathToCompiledFile(Filename As String)

Dim XLSPadlock As Object

On Error GoTo Err

Set XLSPadlock = Application.COMAddIns("GXLSForm.GXLSFormula").Object

PathToCompiledFile = XLSPadlock.PLEvalVar("XLSPath") & Filename

Exit Function

Err:

PathToCompiledFile = ""

End Function

 

Then, you can access a companion file like this:

Dim wk As Workbook

Set wk = Workbooks.Open(PathToCompiledFile("Test File.xlsx"), False, False)

MsgBox wk.Sheets(1).Cells(1, 1).Value

wk.Close

 


Copyright © 2021 G.D.G. Software