Home > Infopath, SharePoint > Launching an Infopath form with a button click

Launching an Infopath form with a button click

When an Infopath form is published to Sharepoint Form Library, the only way to open a new form is either my navigating to the corresponding sharepoint library and click “New” or by clicking on the “Fill Out This Form” menu.

In order to open a new Infopath Form elsewhere in the Sharepoint site, you can use the below script and use a button click to achieve the same. As shown in the script below all you need is the sharepoint document library link.

<script type="text/vbscript" language="vbscript">
	Dim urlLibrary
	Dim urlTemplate
	
	urlLibrary = "http://sharepoint/sites/teamsite/DocLibrary"
	urlTemplate = urlLibrary + "/forms/template.xsn"

	Sub CreateNewInfoPathDocument
	  dim objOpenXMLDocuments
	  set objOpenXMLDocuments = Createobject("SharePoint.OpenXMLDocuments")
	  objOpenXMLDocuments.CreateNewDocument2 window, urlTemplate, urlLibrary
	End Sub
</script>

<!--Button Code-->

<button onclick="CreateNewInfoPathDocument()">Create New</button>
Advertisements
  1. Nancy
    April 8, 2010 at 3:25 PM

    This looks interesting- can you elaborate a bit more on the Button code?

    • BALAJI BASKAR
      April 8, 2010 at 4:35 PM

      “OpenXMLDocuments” is an ActiveX control that enables us to open forms based on template. In order to achieve this we use “CreateNewDocument2” method (the “2” is appended to avoid conflicts and to distinguish between the old and new methods) and this accepts 3 paramaters. The 1st parameter is the pointer to the IE instance, 2nd parameter would be template location (the URL location of the Infopath form that was published to Sharepoint library and the 3rd parameter is the save location (the default save location for the newly opened Infopath forms).

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: