Click here to Skip to main content
15,880,469 members
Articles / Desktop Programming / Windows Forms
Article

Automating the Deployment of an Office InfoPath Form Templates

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
2 May 20071 min read 43.2K   361   17   5
This tool move the previously-published infopath form templates to a new location.

Introduction

Do you have several InfoPath forms and deployed to one location (Server)? Do you want to move them to another location? It is a pain, don't you think?? Here is the tool to deploy the InfoPath forms to any other network location.

Screenshot - forms_publishing_tool.jpg

Background

I know, some one might be thinking why we need several forms; can't you have multiple views in one form and deploy that form to server? Here is the problem we had with multiple views sharing the one data source. If you have a data field that is shared by multiple views and each view use that field differently, if one view changes the field value the other views will also affect with the change. So we decided to go with different forms for each view. The next hectic job is deploying them. Especially when you have multiple environments like development, QA and production, it is very tough to publish manually to each environment. I found an article on Microsoft site to automate the forms publishing. Unfortunately the code was in Jscript, and then I decided to develop a tool.

Using the code

Sub FixupXSN(ByVal xsnInputPath As String, ByVal xsnOutputPath As String, ByVal publishUrl As String)

Try

If Not File.Exists(xsnInputPath) Then

MessageBox.Show("File does not exist: " + xsnInputPath)

Exit Sub

End If

' Create temporary folder and explode the XSN

'Dim tempFolderPath = Directory.CreateDirectory(PathCombine(Path.GetTempPath, Path.GetTempFileName)).FullName

Dim tempFolderPath = PathCombine(Path.GetTempPath, Path.GetFileNameWithoutExtension(Path.GetTempFileName))

tempFolderPath = Directory.CreateDirectory(tempFolderPath).FullName

ExtractFilesFromXSN(xsnInputPath, tempFolderPath)

' Modify the XSF in place 

Dim xsfPath As String = PathCombine(tempFolderPath, "manifest.xsf")

Dim hsAttributesAndValues As New Hashtable

hsAttributesAndValues.Add("publishUrl", publishUrl)

hsAttributesAndValues.Add("publishSaveUrl", xsnOutputPath)

' Generate the new XSN

CreateXSNFromFiles(tempFolderPath, "manifest.xsf", xsnOutputPath)

' Cleanup

'File.Delete(tempFolderPath)

Catch ex As Exception

ShowMessage(ex.Message)

Trace(ex.StackTrace)

End Try

End Sub

Points of Interest

I learned how to use the CABSDK tool in this development process.

References

http://msdn2.microsoft.com/en-us/library/aa192521(office.11).aspx

History

4/20/2007 Created.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer (Senior)
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionRegarding License Pin
DeepakM69015-Jan-17 18:57
DeepakM69015-Jan-17 18:57 
QuestionHave a problem Pin
Member 934384416-Aug-12 3:58
Member 934384416-Aug-12 3:58 
GeneralCABSDK Pin
Crooze2111-Dec-07 5:43
Crooze2111-Dec-07 5:43 
QuestionXsnFixup.js with InfoPath 2007 Pin
ltuttini12-Jun-07 10:46
ltuttini12-Jun-07 10:46 
AnswerRe: XsnFixup.js with InfoPath 2007 Pin
jnky_boy24-Feb-10 23:39
jnky_boy24-Feb-10 23:39 
I also tried the script with no success - I couldn't find eithre the makecab file, or the xsn file. But, if you examine the script, you may try to add this line:
var g_Xsf2Namespace = "http://schemas.microsoft.com/office/infopath/2006/solutionDefinition/extensions"

and also alter this line to include the second selection namespace:
xsfDom.setProperty( "SelectionNamespaces", "xmlns:xsf='" + g_XsfNamespace + "'," + " xmlns:xsf2='" + g_Xsf2Namespace + "'" );

Give it a try!

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.