Open a Shared Workbook
If the local file is linked to a shared workspace, opening that file automatically connects to the SharePoint site and updates the local file. The user may have to sign on to the SharePoint site, and Excel displays the update status (Figure 2-9).
If the local workbook is not linked, or if the workbook is not stored locally, you can open the workbook from the SharePoint site. If you double-click on a workbook in the SharePoint site, Excel opens the workbook as Read-Only. To open the workbook for editing, select Edit from the pop-up menu on the site (Figure 2-10).
Note
Use sharepointobj. Files. Add to add files to an existing workspace. CreateNew always creates a new workspace (which isn’t always what you want).
How to do it
To open a workbook from a shared workspace in code, simply use the Workbooks collection’s Open
method. For linked workbooks, use the local address of the file:
Application.Workbooks.Open "ch02.xls"
Figure 2-9. Opening a workbook linked to a shared workspace
Figure 2-10. Opening a shared workbook from the SharePoint site
For workbooks that aren’t stored locally, use the address of the workbook from the SharePoint site:
Application.Workbooks.Open "http://excelnotebook.sharepointsite.com/" & _ "ch02/Shared Documents/ch02.xls"
Multiple ...
Get Excel 2003 Programming: A Developer's Notebook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.