Export to (Tab Delimited) Text File - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Export to (Tab Delimited) Text File

Last post 07-25-2008 06:04 PM by PJagger. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 05-30-2008 05:56 PM

    • PJagger
    • Top 500 Contributor
      Male
    • Joined on 11-19-2007
    • Australia
    • Posts 40

    Export to (Tab Delimited) Text File

    Hi all,

    Currently I am manually exporting data to Excel then saving the Excel import as an (MS-DOS) text file.  Surely there is a way to export directly to the text file using code!  I am using jscript, however I am not averse to redesigning the form in another script if necessary.

    Any help would be greatly appreciated.

    Regards Phil.

  • 06-26-2008 07:56 AM In reply to

    Re: Export to (Tab Delimited) Text File

  • 06-26-2008 03:52 PM In reply to

    Re: Export to (Tab Delimited) Text File

    What you are trying to do will probably require that your form be full trust. Then you will need to generate in code the content of the text file, access the file system via code, create a new text file, stuff your string into it, and close the file. You should be able to find information on the process of creating a new text file via javascript on the web.

  • 06-27-2008 03:43 AM In reply to

    • PJagger
    • Top 500 Contributor
      Male
    • Joined on 11-19-2007
    • Australia
    • Posts 40

    Re: Export to (Tab Delimited) Text File

    Thanks Geg for you reply.  My form is full trust, however, I have not been successful in finding any help on the web.  Is anyone out there able to point me in the right direction?

    Regards - Phil

  • 06-27-2008 10:45 AM In reply to

    Re: Export to (Tab Delimited) Text File

    What you are interested in is called WSH (Windows Script Host).

    Do a Google search for "wsh save text file".

  • 07-02-2008 06:51 AM In reply to

    • PJagger
    • Top 500 Contributor
      Male
    • Joined on 11-19-2007
    • Australia
    • Posts 40

    Re: Export to (Tab Delimited) Text File

    Thanks Greg,

    I'm making progress.  I have implemented the following script successfully:

    {
    var fso = new ActiveXObject("Scripting.FileSystemObject");
    var FileObject = fso.OpenTextFile("\\\\Eaglet\\Share\\Test.txt", 2, true,0); 
    FileObject.Write("Hello Baby");
    FileObject.Close()
    }

    My problem now is that I don't know how to substitute \\\\Eaglet\\Share\\Test.txt with a field from the form (which contains a path and filename based on a Master Template for the user's domain.  I have tried to use the following...

    XDocument.DOM.selectSingleNode("/my:myFields/my:ExportDetails/my:ExportPath/my:Test").text

    ...where my:Test contains the path and filename.  I get an error message "Infopath cannot complete this action, because of an error in the form's code".

    Any suggestions?
    BTW I'm not sure why, but using double backslashes in the above script was the only way to get it to work.  The field designated by my xpath statement also has double backslashes.

    Regards - Phil

  • 07-14-2008 10:48 AM In reply to

    Re: Export to (Tab Delimited) Text File

    The backslash is an escpae character used to identify other characters--and beyond the scope of this discussion. However, because it is an escape character, you must use a double backslash to identify that you want to use the "actual" backslash character.

    What you might try doing (because I haven't tried this myself) is to see whether using a single backslash character in the field value works. It might be that the code will automatically escape those characters since they are not a hard-coded string.

  • 07-25-2008 06:04 PM In reply to

    • PJagger
    • Top 500 Contributor
      Male
    • Joined on 11-19-2007
    • Australia
    • Posts 40

    Re: Export to (Tab Delimited) Text File

    Hey Greg,

    Sorry for the delayed response, I have been acutely ill and bedridden.

    I tried without the double backslashes and it worked using the selectSingleNoe function!

    Now my challenge is the fill the text file in tab delimited format so it matches what the excel export produced.

    Regards - Phil

Page 1 of 1 (8 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.