Greeting,
Can anyone help me (again) on how to add index field to file name for my custom csv export?
Recently I've had help from a member to enclosed double quotes on csv export here.
As you can see, in order to enclose double quotes, I need to define also the file name output:
This restricts me to one file naming as defined.
Is there any way that I can implement
as an output for my custom csv file name?
Thank you in advance.
Can anyone help me (again) on how to add index field to file name for my custom csv export?
Recently I've had help from a member to enclosed double quotes on csv export here.
As you can see, in order to enclose double quotes, I need to define also the file name output:
Dim namafiledetail as string = "D:\YOURTARGETFOLDER\export.csv"
This restricts me to one file naming as defined.
Is there any way that I can implement
Index:\Document Section 1\NAME
as an output for my custom csv file name?
Thank you in advance.
Comments
4 comments
dim namafiledetail as string = "d:\YOURTARGETFOLDER\" & document.field("Document Section1\NAME").value & ".csv
Hopefully this helps you. Basic script done for a short customer demo to combine standard capture fields with table line items as ABBYY seems to export it into different files by default.
' Declare variables.
Dim fso, txtFile, fileName, table, row, cell, fixAdress, cellCtr
' Create file system object.
Set fso = CreateObject("Scripting.FileSystemObject")
' Set the filename.
'fileName = "\\mypc\abbyy_export\export_" & me.Field("Document Section 1\blkAccount").Value & ".csv"
fileName = "\\mypc\abbyy_export\export.csv"
Set table = me.Field("Document Section 1\blkTable1")
' If the export file doesn't exist, then create it.
If Not fso.FileExists(fileName) Then
Set txtFile = fso.CreateTextFile(fileName, true)
For Each row In table.items
' Fix the address field which may have comma's and all kinds of weird shit.
fixAddress = me.Field("Document Section 1\blkAddress").Value
fixAddress = replace(fixAddress, vbLf, "")
fixAddress = replace(fixAddress, ",", " ")
fixAddress = replace(fixAddress, vbTab, "")
' Write the single document row values first, followed by the table cell values.
txtFile.Write me.Field("Document Section 1\blkAccount").Value & "," & me.Field("Document Section 1\blkTakenBy").Value & "," &_
me.Field("Document Section 1\blkDate").Value & "," & me.Field("Document Section 1\blkTime").value & "," &_
me.Field("Document Section 1\blkWaybillDateTime").Value & "," & me.Field("Document Section 1\WaybillTime").value & "," &_
me.Field("Document Section 1\blkWaybill").Value & "," & fixAddress & "," &_
me.Field("Document Section 1\blkAttention").value & "," & me.Field("Document Section 1\blkNumber").value & ","
' Write the individual cell values.
cellCtr = 0
For each cell In row.Children
If cellCtr = 1 then
txtFile.Write cell.value
Else
txtFile.Write cell.value & ","
End if
cellCtr = cellCtr + 1
Next
txtFile.WriteBlankLines 1
Next
' If the export file does exist, then append to it.
Else
Set txtFile = fso.OpenTextFile(fileName, 8, True)
For Each row In table.items
' Fix the address field which may have comma's and all kinds of weird shit.
fixAddress = me.Field("Document Section 1\blkAddress").Value
fixAddress = replace(fixAddress, vbLf, "")
fixAddress = replace(fixAddress, ",", " ")
fixAddress = replace(fixAddress, vbTab, "")
' Write the single document row values first, followed by the table cell values.
txtFile.Write me.Field("Document Section 1\blkAccount").Value & "," & me.Field("Document Section 1\blkTakenBy").Value & "," &_
me.Field("Document Section 1\blkDate").Value & "," & me.Field("Document Section 1\blkTime").value & "," &_
me.Field("Document Section 1\blkWaybillDateTime").Value & "," & me.Field("Document Section 1\WaybillTime").value & "," &_
me.Field("Document Section 1\blkWaybill").Value & "," & fixAddress & "," &_
me.Field("Document Section 1\blkAttention").value & "," & me.Field("Document Section 1\blkNumber").value & ","
' Write the individual cell values.
cellCtr = 0
For each cell In row.Children
If cellCtr = 1 then
txtFile.Write cell.value
Else
txtFile.Write cell.value & ","
End if
cellCtr = cellCtr + 1
Next
txtFile.WriteBlankLines 1
Next
End If
' Coup de grace.
txtFile.close
Set txtFile = Nothing
Set fso = Nothing
Please sign in to leave a comment.