Sections Collection Object
Description
A collection of all the Section objects in a binder, whether they're visible or hidden.
Using the Sections Collection
Use the Sections property to return the Sections collection. The following example displays the number of sections in Binder1.obd.
Set myBinder = GetObject("C:\Binder1.obd", "OfficeBinder.Binder")
MsgBox "there are " & myBinder.Sections.Count & _
" sections in this binder"
Use the Add method to create a new section or to add an existing file as a section. The following example adds a blank Microsoft Excel workbook section to the newly created binder.
Set myBinder = CreateObject("OfficeBinder.Binder")
myBinder.Sections.Add Type:="Excel.Sheet"
The following example opens an existing binder and adds the Word file Samples.doc as the last section in the binder.
Set myBinder = GetObject("C:\Binder1.obd", "OfficeBinder.Binder")
myBinder.Sections.Add _
FileName:="C:\Program Files\Microsoft Office\Winword\Samples.doc"
Use Sections(index), where index is the number of the section you want to return, to return a single Section object. The following example sets the name of the second section in Binder1.obd to "Budget 95," and then it saves the changes.
Set myBinder = GetObject("C:\Binder1.obd", "OfficeBinder.Binder")
If myBinder.Sections(2).Type = "Excel.Sheet.8" Then
myBinder.Sections(2).Name = "Budget 95"
MsgBox "Binder contents have changed."
End If
myBinder.Save
Properties
Count property, Item property, Parent property.
Methods
Add method.