Skip to Main Content
Excel 2003 Programming: A Developer's Notebook
book

Excel 2003 Programming: A Developer's Notebook

by Jeff Webb
August 2004
Intermediate to advanced content levelIntermediate to advanced
312 pages
8h 30m
English
O'Reilly Media, Inc.
Content preview from Excel 2003 Programming: A Developer's Notebook

Share a Workbook

Anything you can do through the task pane, you can also do in code—actually, you can do more.

Use the Workbook object’s SharedWorkspace property to work with shared workspaces in Excel. The SharedWorkspace property returns a SharedWorkspace object that you use to share the workbook, update the workbook, and navigate among other elements in the shared workspace.

How to do it

Use the SharedWorkspace object’s CreateNew method to create a new shared workspace and add a workbook to it:

   ThisWorkbook.Save
   ThisWorkbook.SharedWorkspace.CreateNew _
   "http://excelnotebook.sharepointsite.com", "ch02"

You must save the workbook before adding it to a shared workspace, otherwise the CreateNew method fails. The preceding code adds the current workbook to the SharePoint site on the excelnotebook.sharepointsite.com server. If you click on Open site in browser in the Excel Shared Workspace pane, Excel displays the new workspace created at http://excelnotebook.sharepointsite.com/ch02 (Figure 2-7).

Note

You can do a lot with shared workspaces through the SharePoint site and the Excel task pane, but by understanding the object model you can customize sharing (almost) any way you like.

If you call CreateNew again, Excel will create another, new workspace and increment the site name to http://excelnotebook.sharepointsite.com/ch02(1) . Remember, Excel creates one workspace folder per document.

In some cases, you may want to add other documents to an existing workspace. To do ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Microsoft® Office Excel 2003 Programming Inside Out

Microsoft® Office Excel 2003 Programming Inside Out

Curtis Frye, Wayne S. Freeze, Felicia K. Buckingham
Excel® 2007 VBA Programmer's Reference

Excel® 2007 VBA Programmer's Reference

John Green, Stephen Bullen, Rob Bovey, Michael Alexander
Office 2003 XML

Office 2003 XML

Simon St. Laurent, Mary McRae, Evan Lenz

Publisher Resources

ISBN: 0596007671Supplemental ContentCatalog PageErrata