This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to run a VBscript when import documents using External Source

Former Member
Former Member
Hi,

Im using EXTERNAL SOURCE feature to import PDF files using XML to get data, I need to import only PDF files that have a XML file, Im trying  using a event handler ( BeforeCreateNewObjectFinalize ) but it doesnt Works when import documents using EXTERNAL SOURCE, how can I resolve this issue ??

Regards,
Parents
  • Former Member
    Former Member
    Hi Craig,

    Thanks for your support, I checked again my code and I modified as follow:


    ' Create text file to log information about this issue
    Set objFileToWrite = CreateObject("Scripting.FileSystemObject").OpenTextFile("C:\temp\listfile.txt",2,true)
    Set objFSO = CreateObject("Scripting.FileSystemObject")

    Dim titleProperty
    titleProperty = MFBuiltInPropertyDefNameOrTitle

    Dim currentTitleProp
    dim filePDF
    dim fileXML

    currentTitleProp = PropertyValues.SearchForProperty(titleProperty)
    filePDF = "D:\Recepcion\Documentos\InformesDeReparto\" & currentTitleProp & ".pdf"
    fileXML = "D:\Recepcion\Documentos\InformesDeReparto\" & currentTitleProp & ".xml"

    objFileToWrite.WriteLine(filePDF)
    objFileToWrite.WriteLine(fileXML)
    objFileToWrite.WriteLine(currentTitleProp)

    If objFSO.FileExists(filePDF) = false or objFSO.FileExists(fileXML) = false Then
    objFileToWrite.WriteLine("Falta el Archivo PDF o XML")
    Err.Raise MFScriptCancel, "Falta el Archivo PDF o XML"
    end if

    objFileToWrite.WriteLine("ARCHIVO IMPORTADO CON EXITO")
    objFileToWrite.Close
    Set objFileToWrite = Nothing

    And works fine !!!!, but I have a doubt, I tried to use Dim file As System.IO.StreamWriter but I got error, Im confusing, I have to use VBScript or Visual Basic ??
Reply
  • Former Member
    Former Member
    Hi Craig,

    Thanks for your support, I checked again my code and I modified as follow:


    ' Create text file to log information about this issue
    Set objFileToWrite = CreateObject("Scripting.FileSystemObject").OpenTextFile("C:\temp\listfile.txt",2,true)
    Set objFSO = CreateObject("Scripting.FileSystemObject")

    Dim titleProperty
    titleProperty = MFBuiltInPropertyDefNameOrTitle

    Dim currentTitleProp
    dim filePDF
    dim fileXML

    currentTitleProp = PropertyValues.SearchForProperty(titleProperty)
    filePDF = "D:\Recepcion\Documentos\InformesDeReparto\" & currentTitleProp & ".pdf"
    fileXML = "D:\Recepcion\Documentos\InformesDeReparto\" & currentTitleProp & ".xml"

    objFileToWrite.WriteLine(filePDF)
    objFileToWrite.WriteLine(fileXML)
    objFileToWrite.WriteLine(currentTitleProp)

    If objFSO.FileExists(filePDF) = false or objFSO.FileExists(fileXML) = false Then
    objFileToWrite.WriteLine("Falta el Archivo PDF o XML")
    Err.Raise MFScriptCancel, "Falta el Archivo PDF o XML"
    end if

    objFileToWrite.WriteLine("ARCHIVO IMPORTADO CON EXITO")
    objFileToWrite.Close
    Set objFileToWrite = Nothing

    And works fine !!!!, but I have a doubt, I tried to use Dim file As System.IO.StreamWriter but I got error, Im confusing, I have to use VBScript or Visual Basic ??
Children
No Data