コミュニティ

Add INDEX Field to File Name For Custom CSV Export Script

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:
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.


この記事は役に立ちましたか?

0人中0人がこの記事が役に立ったと言っています

コメント

4件のコメント

  • Avatar
    Permanently deleted user


    dim namafiledetail as string = "d:\YOURTARGETFOLDER\" & document.field("Document Section1\NAME").value & ".csv
    0
  • Avatar
    Permanently deleted user
    @ScanAddicted I need to buy you some beers!
    0
  • Avatar
    Permanently deleted user
      Hey, @Jakarta Development - Is there any way you can give me some example of custom csv export scripts? 
    0
  • Avatar
    Permanently deleted user

    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

    0

サインインしてコメントを残してください。