How to export date from a worksheet as text in txt-file?

Hello Folks,
in the event that my customers receive an update, it must be possible the data that already exists to secure or to export in a separate File to then be able to re-read in the new programm-version.
I’ve written this using VBA subroutines, which also function in the source code. In the compiled programm-version these subroutines are not executed.
I ask in this regard for your help!
best regards
UTS

How do you trigger these routines? With workbook events?

Hi and thanks for your reply.
I use this VBA-Code:
Public Sub export_Tageswerte()
'falls die Zieldatei noch nicht vorhanden ist, wird sie erstellt
Dim Datei As String, Text As String
Dim zeigen
Set WSa = Worksheets(“Commissions”)
If Not IsNumeric(WSa.Cells(7, “E”)) Then Exit Sub
On Error GoTo Fehler

'Zieldatei festlegen => Tageswerte
Datei = ThisWorkbook.Path & "\" & "MAPTrack2.txt"
Open Datei For Output As #1            'Zieldatei öffnen

'i = WSa.Cells(7, "C") 'Start-Zeile
i = 10 'Start-Zeile
j = WSa.Cells(7, "E") 'End-Zeile

For Zeile = i To j
    String1 = WSa.Cells(Zeile, "C") & ";" 'Datum
    String1 = String1 & WSa.Cells(Zeile, "D") & ";"
    String1 = String1 & WSa.Cells(Zeile, "E") & ";"
    String1 = String1 & WSa.Cells(Zeile, "F") & ";"
    String1 = String1 & WSa.Cells(Zeile, "H") & ";"
    String1 = String1 & WSa.Cells(Zeile, "J") & ";"
    String1 = String1 & WSa.Cells(Zeile, "K") & ";"
    String1 = String1 & WSa.Cells(Zeile, "L") & ";"
    String1 = String1 & WSa.Cells(Zeile, "X") & ";"
    String1 = String1 & WSa.Cells(Zeile, "Y")
    Print #1, String1 'Daten in Datei schreiben
Next Zeile
Close #1    'Zieldatei schließen

’ zeigen = Shell(Environ(“windir”) & "\notepad.exe " & Datei, 1)
Exit Sub

Fehler:
Close #1
MsgBox "FehlerNr.: " & Err.Number & vbNewLine & vbNewLine _
& "Beschreibung: " & Err.Description, vbCritical, "Fehler"
End Sub

In the uncompiled Version it realy works fine.

with best regards

The problem is ThisWorkbook.Path because it returns a virtual path so you can’t access it for real.
As a workaround, XLS Padlock provides a VBA function that gives you the path to the folder where the EXE lies. By replacing ThisWorkbook.Path to the function call, it will then work again.
The function is explained in the user guide:

Example 2: you want to access external files with VBA code. External files must be in the same folder as the EXE
file. You can use this code:
Public Function PathToFile(Filename As String)
Set XLSPadlock = Application.COMAddIns(“GXLSForm.GXLSFormula”).Object
PathToFile = XLSPadlock.PLEvalVar(“EXEPath”) & Filename
End Function
If you pass Myfile.ext to this function, it returns the full path to the file, provided that the file is in the same
folder as the EXE file.

So in your case, it would be something like:

Set XLSPadlock = Application.COMAddIns("GXLSForm.GXLSFormula").Object
Datei = XLSPadlock.PLEvalVar("EXEPath") & "MAPTrack2.txt"

Make sure the folder where the EXE lies is not read-only.