Syntax

expression.Add(FileName, ParentFolder, OverwriteIfFileAlreadyExists, KeepInSync)

expression Required. A variable that represents a object.

Parameters

Name Required/Optional Data Type Description
FileName Required String The path and filename of the file to be added to the current shared workspace.
ParentFolder Optional SharedWorkspaceFolder The subfolder in which to place the file, if not the main document library folder within the shared workspace. Add the file to the main document library folder by leaving this optional argument empty.
OverwriteIfFileAlreadyExists Optional Boolean True to overwrite an existing file by the same name. Default is False.
KeepInSync Optional Boolean True to keep the local copy of the document synchronized with the copy in the shared workspace. Default is False.

Example

The following example adds a new file to the files collection of the shared workspace.

Visual Basic for Applications
 Dim swsfile As Office.SharedWorkspaceFile Set swsfile = ActiveWorkbook.SharedWorkspace.Files.Add( _ "C:\MyWorkbook.xls", _, True, True) MsgBox "New file URL: " & swsfile.URL, _ vbInformation + vbOKOnly, _ "New File in Shared Workspace Files" Set swsfile = Nothing 

See also: