Excel 2003 Programming: A Developers Notebook (Developers Notebook)
|
2.11. Update a Shared List
There are several ways to update a shared list:
Note: If you're not upto- date, there's no point in sharing. 2.11.1. How to do it
From Excel, use the Data From code, use the ListObject's Refresh method to discard changes to the list on the worksheet and refresh it with data from the SharePoint server: lst.Refresh Use the UpdateChanges method to synchronize the worksheet list with the SharePoint list: lst.UpdateChanges xlListConflictDialog
If two authors modify the same item in a list, a conflict will occur when the second author updates his list. The iConflictType argument determines what happens when a conflict occurs. Possible settings are:
If the worksheet list is not shared, UpdateChanges causes an error. The following code synchronizes a list and overwrites conflicting items with the worksheet version of the item (local version wins): Set ws = ThisWorkbook.Worksheets("Lists") Set lst = ws.ListObjects("Excel Objects") lst.UpdateChanges xlListConflictRetryAllConflicts The following code synchronizes a list and overwrites conflicting items with the SharePoint version of the item (server version wins): Set ws = ThisWorkbook.Worksheets("Lists") Set lst = ws.ListObjects("Excel Objects") lst.UpdateChanges xlListConflictDiscardAllConflicts
2.11.2. How it works
Excel compares the data in the worksheet list with the change history in the SharePoint list and flags items that conflict when the worksheet list is synchronized. How the user responds (or how iConflictType is set) determines which changes become permanent. |
|