Modifying XSN Files (InfoPath)

So the other morning apparently one of my ‘eval’ functions in an InfoPath form I was working on caused an infinite loop (my best guess: This causes the InfoPath form to crash and then error out everytime you try and open it afterwards.

When working in SharePoint you could restore to the previous version and redo the work (without the infinite loop, or whatever caused your error and inability to use/modify the form) if you had it stored in SharePoint, but my last save was hours ago. So I decided I would extract the XSN, modify what I think the offending expression function was (eval statements) in a specific view and then put it all back together again. That way I could avoid redoing work.

First of all you CAN save a form template’s form file’s to a folder, modify them, and combine them again into an XSN using InfoPath. However you MUST be able to open the form in design mode. Doing this is pretty simple just follow the directions at the bottom of this Microsoft article:

In my circumstance I could not even open the form in design mode as it would error out. In case anyone else runs into this I am hoping this helps them.

First off an XSN file is just a container (CAB file) of many other files. So even without InfoPath this should be easy.

  1. In order to modify these files you can just rename the .XSN file to .CAB and then extract its contents using WinRAR. You could also use renaming the .XSN file to .CAB I would be able to extract it’s contents to a folder on my local drive. (I used WinRAR for this, you could use many other programs and alternatives (
  2. I then modified my file and saved it. (Removing the evil eval loop.)
  3. I then created a Directive file so that I could use it to make a CAB. (This allows me to add many items to a cab rather than doing it individually.)To do this I just created a simple .txt file and populated it similar to the following:
    ; MSDN Sample Source Code MakeCAB Directive File


    .Set CabinetNameTemplate=ReCreated.XSN

    ; Change DiskDirectoryTemplate to where you want the CAB/XSN saved.

    .set DiskDirectoryTemplate=”C:\InfoPath XSN”
    .Set Cabinet=on
    .Set Compress=on

    ; List Every File You Want Added To The CAB (XSN)

    “C:\Users\rharbrid\Desktop\OpportunityProfile – Copy\Example.xsd”
    “C:\Users\rharbrid\Desktop\OpportunityProfile – Copy\manifest.xsf”
    “C:\Users\rharbrid\Desktop\OpportunityProfile – Copy\sampledata.xml”
    “C:\Users\rharbrid\Desktop\OpportunityProfile – Copy\Template.xml”
    “C:\Users\rharbrid\Desktop\OpportunityProfile – Copy\upgrade.xsl”
    “C:\Users\rharbrid\Desktop\OpportunityProfile – Copy\view1.xsl”

    ; End Of The File

  4. Next you run the makecab command with the directive files. Example: “makecab /f DirectiveForXSN.txt”The MakeCab.exe file should exist in the Windows\System32 folder. If it doesn’t for any reason you can download the CAB SDK from Microsoft located here: and for information on the tools located in it see this article here:

And that’s it. You should now have a corrected and functioning XSN, and resolved the error that caused InfoPath to crash each time it opened the form in design mode.

Hope this helps someone out there,
Richard Harbridge

Explore posts in the same categories: InfoPath, Issue Resolution, SharePoint 2007

Tags: , ,

You can comment below, or link to this permanent URL from your own site.

One Comment on “Modifying XSN Files (InfoPath)”

  1. Raj Says:

    Great article. Really helpful. Thanks for also providing references to the Microsoft knowledge base.

Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

%d bloggers like this: