Hello,
I am having a problem with some VBA functions. What I want to do is to change the .xlsc path when user move the compiled file .exe to a new folder. Therefore what I need to do is to change the path contained in the text file .dat
To get the path of current folder I am using the function of your manual “PathToFile” (see below) and it works well, but when I use the code DIR it returns always “empty”. It is like the files .dat and .xlsx do not exist but they exist in the same folder of .exe
In below code, strings “fullpathtemplate” and “fullpathtemplatexlsc” works correctly but DIR(fullpathtemplate) does not work when the Excel file is compiled by XLSPADLOCK. It works well if file is not compiled (.xlsb)
Any idea why it does not work? I have tested in 2 different PCs with the same problem. I am using last release of XLSPADLOCK with Excel 32 bits (tested in Windows 10/Excel 2016 and Windows 7/Excel 2010).
PART OF THE VBA CODE:
namewoextension = Left(ThisWorkbook.Name, Len(ThisWorkbook.Name) - 5)
pathtemplate = PathToFile("")
fullpathtemplate = pathtemplate & namewoextension & ".dat"
fullpathtemplatexlsc = pathtemplate & namewoextension & “.xlsc”
TestStr = Dir(fullpathtemplate)
TestStr2 = Dir(fullpathtemplatexlsc)
Public Function PathToFile(Filename As String)
On Error GoTo Err
Set XLSPadlock = Application.COMAddIns(“GXLSForm.GXLSFormula”).Object
PathToFile = XLSPadlock.PLEvalVar(“EXEPath”) & Filename
Exit Function
Err:
PathToFile = ""
End Function