Launch an InfoPath form from a SharePoint page

Here is a handy piece of sample code that can be used within a SharePoint web page as JScript that will launch an InfoPath form without using the Open/Save dialog (which sometimes causes users to download the XSN file onto their computer).  Users will still get a security prompt, which you can disable with policy if this is for intranet usage.

function LaunchInfoPath(templateURL,saveLocation)
{
//savelocation sample: "http://server/site/document library/" or "file://c:"
//templateURL sample: "http://server/site/form library/forms/template.xsn"
//The function teturns true if it worked, false if it didn't


var infopath = new ActiveXObject("SharePoint.OpenXMLDocuments.1");
var result= infopath.CreateNewDocument2(window, templateURL,saveLocation);
return result;
}

By the way, no warranty is expressed or implied here. This code is just a sample. Your mileage may vary.

1 Comment

  • Thankyou!!

    Don't suppose you have any idea how to populate a textbox on the infopath form that you have opened from the template here ???

Comments have been disabled for this content.