I use XLSPadlock to compile and Paquet Builder for setup. When I choose “My Documents” directory as destination in Paquet Builder, saving .xlsc file works fine. When choosing “Program Files” directory in Paquet Builder, my program gets installed in the “Program Files” directory. However, no changes (.xlsc file) are (or can be) saved to my program folder in the Program Directory!
I am using code found in your User Guide to save the .xlsc file by calling “SaveSecureWorkbookToFile” from a module :
As explained, saving to My Document Directory works fine, but trying to save to the Programs Directory doesn’t work. I am not sure whether Windows User Account Control (UAC) security features prohibits me from saving to the “Programs Directory” or am I missing something in your suggested code?
Not sure I fully follow as I struggle to understand it at times. However Paquet builder is the means, I believe, of delivering the executable, plus any additional documentation to to packaged in with it - but that shouldn’t (or wouldn’t) include the .xlsc file anyway.
Also as I understand when saving the files from within the exe (as opposed to the .xlsm) you need to allow XLSPadlock to determine the path file with a special function:
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
I am saving from my .exe (presumably in the correct way). I am using the same name for .xlsc file (Protected Workbook) as my .exe (Compiled Workbook) name.
I get .exe Workbook Name by calling code copied into a Module (copied from UserGuide):
Public Function GetEXEFilename()
Dim XLSPadlock As Object
On Error GoTo Err
Set XLSPadlock = Application.COMAddIns(“GXLSForm.GXLSFormula”).Object
GetEXEFilename = XLSPadlock.PLEvalVar(“EXEFilename”)
Exit Function
Err:
GetEXEFilename = “”
End Function
I then change the file extention from “.exe” to “.xlsc”:
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
Then Set the File Name:
MySave = PathToFile(XlscFileName)
I then call SaveSecureWorkbookToFile from module:
Public Function SaveSecureWorkbookToFile(Filename As String)
Dim XLSPadlock As Object
On Error GoTo Err
Set XLSPadlock = Application.COMAddIns(“GXLS.GXLSPLock”).Object
SaveSecureWorkbookToFile = XLSPadlock.SaveWorkbook(Filename) Exit Function
Err:
SaveSecureWorkbookToFile = “”
End Function
And then last step:
SaveSecureWorkbookToFile MySave
All of this works fine when I save to “My Documents Directory” (or anywhere else), but definitely not when I try to save to the “Programs Directory”!
I don’t know how to by-pass Windows User Account Control (UAC)…if this is the problem…?
You can’t definitively write to the “Program Files” directory without account elevated rights. It’s a security measure and it cannot be overridden unless you run the EXE file with administrative rights (not recommended though).
The location is either AppData or My Documents. I’d still stick with My Documents because it’s the common place where end users will look for their save files at first.
I do not necessarily want to give users account elevated rights when using this program. I just thought that there could be an “easy way out” with either XLSPadlock or Paquet Builder. I will therefore stick to the Documents Directory.