Section 2.11.Update a Shared List


2.11. Update a Shared List

There are several ways to update a shared list:

  • Refreshing discards local changes and updates the (local) worksheet list with data from the SharePoint server.

  • Synchronizing updates both the worksheet list and the SharePoint list. Conflicts between local edits and edits from other users can be resolved by the user who is synchronizing.


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 List menu to refresh or synchronize a list.

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:

SettingDescription

xlListConflictDialog

Displays the Resolve Conflicts and Errors dialog box to resolve the conflict (this the default).

xlListConflictRetryAllConflicts

Replaces conflicting data on the SharePoint server with data from the worksheet.

xlListConflictDiscardAllConflicts

Replaces conflicting data on the worksheet with updates from the SharePoint server.

xlListConflictError

Updates the items that do not conflict and generates an error"Cannot update the list to Windows SharePoint Services" leaving the conflicting items unchanged.


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.



    Excel 2003 Programming. A Developer's Notebook
    Excel 2003 Programming: A Developers Notebook (Developers Notebook)
    ISBN: 0596007671
    EAN: 2147483647
    Year: 2004
    Pages: 133
    Authors: Jeff Webb

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net