16.01.2013 Views

Microsoft Sharepoint Products and Technologies Resource Kit eBook

Microsoft Sharepoint Products and Technologies Resource Kit eBook

Microsoft Sharepoint Products and Technologies Resource Kit eBook

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

1030 Part X: <strong>Microsoft</strong> Office 2003 Integration with SharePoint <strong>Products</strong> <strong>and</strong> <strong>Technologies</strong><br />

When you interact with the Jet engine directly through VBA, you need to match them<br />

manually. The long string in the example that starts with "Windows SharePoint Services"<br />

<strong>and</strong> ends with "TABLE=Parts" identifies a particular SharePoint list.<br />

To programmatically import or add links to data in Windows SharePoint Services,<br />

there are two ways to identify the correct GUID. The easy way is to add a link<br />

manually between the desired SharePoint list <strong>and</strong> the Access database, <strong>and</strong> then<br />

open the linked table in design view. The Description property of the linked table<br />

contains the necessary linking string. Obviously, this is less than useful when linking<br />

to arbitrary lists. You can also use the Windows SharePoint Services Web service<br />

interface to Windows SharePoint Services, which exposes a Lists.GetList method. This<br />

method gets the name of a list on a specified SharePoint site <strong>and</strong> returns detailed<br />

information, including the GUID that identifies the list. The Windows SharePoint<br />

Services Web service interface is discussed in more detail later in this document.<br />

If you created a link between a SharePoint list <strong>and</strong> an Access database, you can<br />

work with it just like any other table. You can execute SQL statements to retrieve or<br />

change data, or open a Recordset <strong>and</strong> manipulate the list programmatically. Access<br />

treats the SharePoint list similar to another table <strong>and</strong> all the table-oriented code you<br />

already know works. An optimistic locking model coordinates concurrency issues,<br />

such as when two users work with the same data at the same time between Windows<br />

SharePoint Services <strong>and</strong> Access.<br />

<strong>Microsoft</strong> Office Excel 2003 Integration<br />

<strong>Microsoft</strong> Office Excel 2003 also integrates with SharePoint lists by implementing an<br />

extension to the Excel 2003 object model to make working with lists distinct from<br />

other activities. The Worksheet object in Excel is extended with a ListObjects collection<br />

that contains individual ListObject objects. The ListObject contains collections of<br />

ListColumns <strong>and</strong> ListRows, <strong>and</strong> the individual ListColumn <strong>and</strong> ListRow objects have<br />

properties that tie them to Excel Range objects.<br />

By default, the ListObjects collection contains native Excel 2003 lists. But you<br />

can hook up one of these lists to a SharePoint site by calling the Publish method of<br />

the corresponding ListObject object.<br />

To create a list from the rectangular area extending from A1 to C8, you could<br />

run the following VBA code:<br />

Public Sub PublishList()<br />

' Get the collection of lists for the active sheet<br />

Dim L As ListObjects<br />

Set L = ActiveSheet.ListObjects<br />

' Add a new list<br />

Dim NewList As ListObject<br />

Set NewList = L.Add(xlSrcRange, Range("A1:C8"), , True)<br />

NewList.Name = "PartsList"<br />

' Publish it to a SharePoint site<br />

NewList.Publish Array("http://server_name/sites/site_name", _<br />

"NewParts"), True<br />

End Sub

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!