@@ -97,13 +97,7 @@ Public Sub ExportTableDataAsTDF(strTable As String)
97
97
intCnt = 0
98
98
For Each fld In rst.Fields
99
99
' Format for TDF format without line breaks
100
- strText = MultiReplace(Nz(fld.Value), _
101
- "\" , "\\" , _
102
- vbCrLf, "{\r\n}" , _
103
- vbCr, "{\r}" , _
104
- vbLf, "{\n}" , _
105
- vbTab, "{\t}" )
106
- cData.Add strText
100
+ cData.Add FormatStringForTDF(Nz(fld.Value))
107
101
intCnt = intCnt + 1
108
102
If intCnt < intFields Then cData.Add vbTab
109
103
Next fld
@@ -191,12 +185,7 @@ Private Sub ImportTableDataTDF(strFile As String)
191
185
End If
192
186
Else
193
187
' Perform any needed replacements
194
- strValue = MultiReplace(CStr(varLine(intCol)), _
195
- "\\" , "\" , _
196
- "{\r\n}" , vbCrLf, _
197
- "{\r}" , vbCr, _
198
- "{\n}" , vbLf, _
199
- "{\t}" , vbTab)
188
+ strValue = FormatStringFromTDF(CStr(varLine(intCol)))
200
189
If strValue <> CStr(varLine(intCol)) Then
201
190
' Use replaced string value
202
191
rst.Fields(varHeader(intCol)).Value = strValue
@@ -220,6 +209,44 @@ Private Sub ImportTableDataTDF(strFile As String)
220
209
End Sub
221
210
222
211
212
+ '---------------------------------------------------------------------------------------
213
+ ' Procedure : FormatStringForTDF
214
+ ' Author : Adam Waller
215
+ ' Date : 7/16/2021
216
+ ' Purpose : Replace line feeds and similar characters with escaped codes for
217
+ ' : representation in tab-delimited format.
218
+ ' : (Using Chr(26) as interim placeholder) See #251
219
+ '---------------------------------------------------------------------------------------
220
+ '
221
+ Private Function FormatStringForTDF (strValue As String ) As String
222
+ FormatStringForTDF = MultiReplace(strValue, _
223
+ "\" , Chr$(26 ), _
224
+ vbCrLf, "\r\n" , _
225
+ vbCr, "\r" , _
226
+ vbLf, "\n" , _
227
+ vbTab, "\t" , _
228
+ Chr$(26 ), "\\" )
229
+ End Function
230
+
231
+
232
+ '---------------------------------------------------------------------------------------
233
+ ' Procedure : FormatStringFromTDF
234
+ ' Author : Adam Waller
235
+ ' Date : 7/16/2021
236
+ ' Purpose : Restore original characters from escaped codes.
237
+ '---------------------------------------------------------------------------------------
238
+ '
239
+ Private Function FormatStringFromTDF (strTDFValue) As String
240
+ FormatStringFromTDF = MultiReplace(strTDFValue, _
241
+ "\\" , Chr$(26 ), _
242
+ "\r\n" , vbCrLf, _
243
+ "\r" , vbCr, _
244
+ "\n" , vbLf, _
245
+ "\t" , vbTab, _
246
+ Chr$(26 ), "\" )
247
+ End Function
248
+
249
+
223
250
'---------------------------------------------------------------------------------------
224
251
' Procedure : GetTableExportSql
225
252
' Author : Adam Waller
0 commit comments