Add Method
Applies To
Sections collection object.
Description
Creates a new section in the specified binder and returns a Section object that represents the new section. You can add a section by either creating a new object or inserting a section based on an existing file.
Syntax
expression.Add(Type, FileName, Before, After)
expression Required. An expression that returns a Sections object.
Type Optional Variant. The type of section to be created. Can be one of the following classes: Excel.Chart, Excel.Sheet, Word.Document, PowerPoint.Show, or PowerPoint.Slide. If this argument is omitted, FileName is required.
FileName Optional Variant. The full path and file name of the file on which to base the section you want to add. If this argument is omitted, Type is required.
Before Optional Variant. The section that the new section will be added before. You cannot specify Before if you've specified After.
After Optional Variant. The section that the new section will be added after. You cannot specify After if you've specified Before.
Remarks
You must specify either Type or FileName. The name specified for Type doesn't need to include the version number included in the value returned by the Type property.
If you omit both Before and After, the section is added after the last section in the binder.
Example
This example adds a Word document to Binder1.obd and names the resulting document "Totals."
Set myBinder = GetObject("C:\Binder1.obd", "OfficeBinder.Binder")
Set newSection = mybinder.Sections _
.Add(Type:="Word.Document", Before:=1)
newSection.Name = "Totals"