Export method - InfoPath Dev
in

InfoPath Dev

Export method

Last post 05-03-2005 04:38 AM by Patrick Halstead. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 04-18-2005 07:04 AM

    • Lee
    • Not Ranked
    • Joined on 07-23-2004
    • United Kingdom
    • Posts 18

    Export method

    Hi

    I want to programmatically export a form to a document library on a SharePoint installation.

    At the moment the form throws an error when it gets the exportline in the code. Does the export method support exporting to a network location?? if not is there another way to do it?

    i am currently using the following line of code to export the form...

    XDocument.View.Export("http://server/sites/sitename/doclib/formname", "MHT")


    cheers for any help it is greatly appreciated

    regards


    Lee A Newson
  • 04-18-2005 06:45 PM In reply to

    Hi Lee,
    Is your form full-trust? Export requires security level 3 (full trust). I hope this helps.


    Patrick Halstead [InfoPath MVP]
    InfoPathDev
    Patrick Halstead
    Project Manager at Qdabra
  • 04-21-2005 01:09 AM In reply to

    • Lee
    • Not Ranked
    • Joined on 07-23-2004
    • United Kingdom
    • Posts 18
    Hi Patrick,

    Yes my form is full trust, to test this functionality i had to grant it full trust and then install it as you cannot test full trust functionality just by previewing the form.

    The way i have done it is that i have a button at the bottom of the form, which, when pressed starts a rule to submit the form to a form library using a data connection (this part works), and in the onclick event for the button i have some custom code that should perform the export to a document library on the same site as the form library, but the form falls over when it gets to the XDocument.View.Export() line.

    any ideas?

    Lee A Newson
  • 04-21-2005 05:05 PM In reply to

    Hi again,

    Why not just create a view onto the XML using the XSL Tool in the SDK? That way, you won't have two versions of the XML file and you don't have to be full trust. We do this all the time. In fact, I believe we have a snippet of code lying around that you can add to a column on your SharePoint view to create a link that when clicked will render the form as HTML.

    Of course, Export should work too. What is the exact error message? Do you have doc lib created?

    Cheers

    Patrick Halstead [InfoPath MVP]
    InfoPathDev
    Patrick Halstead
    Project Manager at Qdabra
  • 04-22-2005 06:45 AM In reply to

    • Lee
    • Not Ranked
    • Joined on 07-23-2004
    • United Kingdom
    • Posts 18
    Hi,

    I have now got a work around for this problem as follows:

    	var DECOID = XDocument.DOM.selectSingleNode("//my:DecoID").text;

    XDocument.View.Export("c:\\DECO " + DECOID + ".doc", "MHT");

    var objApp = new ActiveXObject("Word.Application");

    objApp.Visible = false;

    objApp.Documents.Open("c:\\DECO " + DECOID + ".doc");

    objApp.ActiveDocument.SaveAs("http://server/sites/sitename/DocLib/DECO%20" + DECOID + ".doc");

    objApp.Quit();


    Its a shame that the Export method did not meet up with expectations... the only way i could get the method to work was by using a local folder path instead of a network location.

    Cheers

    Lee

    Lee A Newson
  • 04-23-2005 01:19 PM In reply to

    Hi Lee,

    Thanks for posting the info on the limitations of Export. The SDK only has an example of exporting to a directory, but I agree it's not clear. Anyway, looks like it doesn't support WebDAV.

    I still think you are better off using the XSL Tool to do the downlevel since it will a) not require any code, b) not result in two files (which could get out of synch), and c) doesn't require full trust.

    Good luck!


    Patrick Halstead [InfoPath MVP]
    InfoPathDev
    Patrick Halstead
    Project Manager at Qdabra
  • 04-25-2005 12:52 AM In reply to

    • Lee
    • Not Ranked
    • Joined on 07-23-2004
    • United Kingdom
    • Posts 18
    Hi Patrick,

    Where can i find that code snippet you mentioned? I have tried looking around the site and maybe i have missed it, but i can't seem to find it.

    cheers

    Lee
  • 05-03-2005 04:38 AM In reply to

    Hi Lee,
    Sorry for the delay. I'll ask someone to post the code snippet.
    More soon,

    Patrick Halstead [InfoPath MVP]
    InfoPathDev
    Patrick Halstead
    Project Manager at Qdabra
Page 1 of 1 (8 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.