Prexens team dev' corner

How-to: Fix "Method 'post' of object 'IOWSPostData' failed" error

Goal of this post

This post aims at providing a step by step solution to an uncommon error which could happen when you try to import an Excel file to a SharePoint 2007 custom list.

Problematic overview

The "Import to a SharePoint List" feature is usually used to create and fill a custom list from an Excel source file.

For an unknown reason, this feature may not work properly on some client workstations whatever the version of SharePoint and Office Excel used. During the import step, the site designer receives the following error message box:


Solution

First we have to point out that this error isn't caused by SharePoint but by Ms Excel, and that the fix will have to be executed on each client workstation - at least site designers workstations - because standard users are not impacted by this error.

The issue will be fixed in two steps: first we need to edit the EXPTOOWS.XLA excel file, and then we have to restore the SharePoint sites collection(s).

Modify EXPTOOWS.XLA
  • Open the Excel add-in "EXPTOOWS.XLA" located by default in "c:\Program Files\Microsoft Office\Office12\<LCID>", where <LCID> is your language identifier (for example, 1033 for a standard English installation, 1036 for a French one).
  • Press ALT+F11 to open the Visual Basic source code editor
  • Comment out the following line : "lVer = Application.SharePointVersion(URL)" by adding a simple quote at the beginning of the line
  • Below the commented line, add the following instruction : IVer = 2
  • Save your changes, and restart the client machine.
Backup and restore site the sites collection

The Excel install is now fixed, and you will be able to import Excel files in custom SharePoint list on the new SharePoint site collections. But in order to make this solution work on the actual site collection, you will have to backup and restore it by using STSADM command line tool which is provided with SharePoint (more information on STSADM command line tool are available by following this link : http://technet.microsoft.com/en-us/library/cc261956.aspx)


Execute the following commands :

stsadm -o backup -url http://PORTAL-URL -filename c:\Backups\BACKUP-FILE.dat

stsadm -o restore -url http://PORTAL-URL -filename c:\Backups\BACKUP-FILE.dat -overwrite


You can now start again the custom list importation from an Excel file, it should now work properly.


How to debug custom STSADM commands

When developing custom STSADM commands, it could be handy to debug our code in the real execution context of STSADM. To do so, you only have to deal with your Visual Studio project configuration.
 
1. Right click your VS project and go to properties
 
2. From Build Events tab, paste the following commands into the Post-buid event command line box
 
"%programfiles%\Microsoft Visual Studio 8\SDK\v2.0\Bin\gacutil.exe" /uf $(TargetName)
"%programfiles%\Microsoft Visual Studio 8\SDK\v2.0\Bin\gacutil.exe" /if "$(TargetPath)"
 
3. From Debug tab, choose Start external program as a Start Action and browse for file C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\STSADM.EXE
 
 
4. In the Command line arguments text box, specify -o <name of your command> and the rest of your input parameters
 
 
5. You can now add break points to your code, run your project and debug your code in real conditions

Categories
Links
  Prexens Web Site
  Charting for SharePoint
  Charting for SharePoint (Codeplex)
  Charting for SharePoint Starter kit

Microsoft Certified Partner