Activate Method

Activates the section in the binder.

Syntax

object.Activate

object

Required. The Section object to activate.

Remarks

Several sections can be selected at the same time, but only one of them can be the active section. If you activate a hidden section, it becomes visible.

Use the SelectedSectionNames property to return or set the array of selected section names.


Activate Method Example

This example creates a new binder, adds a Microsoft Excel workbook and a Word document, and then activates the first section.

Set newBinder = CreateObject("Office.Binder")

newBinder.Visible = True

newBinder.Sections.Add Type:="Excel.Sheet"

newBinder.Sections.Add Type:="Word.Document"

newBinder.Sections(1).Activate


ActiveSection Property

Accessor. Returns a Section object that represents the active section in the binder. If the binder doesn't contain any visible sections, an error occurs. Read-only.

Remarks

To make a section the active section, use the Activate method.


ActiveSection Property Example

This example opens Binder1.obd and creates a copy of the first section if its type is Excel.Sheet.5. The new section is inserted after the last section in the binder.

Set newBinder = GetObject("Binder1.obd", "Office.Binder")

newBinder.Visible = True

newBinder.Sections(1).Activate

If ActiveSection.Type = "Excel.Sheet.5" Then

newBinder.ActiveSection.Copy

End If


Add Method

Creates a new section in the binder and returns a Section object that represents the new section. You can add a section by either creating a new object or inserting the section from an existing file.

Syntax

object.Add(type, fileName, before, after)

object

Required. The Sections object.

type

Optional. The type of section to create. One of Excel.Chart, Excel.Sheet, Word.Document, PowerPoint.Show, or PowerPoint.Slide. If type is omitted, fileName is required.

fileName

Optional. The full path and filename of the file containing the section you want to add. If fileName is omitted, type is required.

before

Optional. Specifies the section that the new section will be added before. You cannot specify before if you specify after.

after

Optional. Specifies the section that the new section will be added after. You cannot specify after if you specify 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 before and after, the section is added after the last section in the binder.


Add Method Example

This example adds a new Word document before the first section in Binder1.obd.

Set newBinder = GetObject("Binder1.obd", "Office.Binder")

newBinder.Visible = True

With newBinder.Sections.Add(Type:="Word.Document", before:=1)

    .Name = "Totals"

End With


Copy Method

Copies the section to another location in the binder. Returns the new Section object.

Syntax

object.Copy(before, after)

object

Required. The Section object.

before

Optional. The section that this section will be copied before. You cannot specify before if you specify after.

after

Optional. The section that this sheet will be copied after. You cannot specify after if you specify before.

Remarks

If you omit before and after, the section is copied after the last section in the binder.


Copy Method Example

This example determines whether the active section of Binder1.obd is of type Excel.Sheet.5. If it is, the example copies the section after the section named "Document."

Set newBinder = GetObject("Binder1.obd", "Office.Binder")

newBinder.Visible = True

If newBinder.ActiveSection.Type = "Excel.Sheet.5" Then

newBinder.ActiveSection.Copy after:="Document"

End If


Count Property

Returns the number of items in the Sections collection object. Read-only.

Remarks

All sections, whether visible or hidden, are included in the count.


Count Property Example

This example displays the number of sections in Binder1.obd.

Set myBinder = GetObject("Binder1.obd", "Office.Binder")

sectionNumber = myBinder.Sections.Count

binderName = myBinder.Name

Set myBinder = Nothing

MsgBox "There are " & sectionNumber & " sections in " _

& binderName


Delete Method

Deletes the Section object.

Syntax

object.Delete

object

Required. The Section object.


Delete Method Example

This example deletes the third section in Binder2.obd.

Set myBinder = GetObject("Binder2.obd", "Office.Binder")

myBinder.Visible = True

myBinder.Sections(3).Delete


Index Property

Returns the index number of the Section object within the Sections collection object. Read-only.

Remarks

All sections, whether visible or hidden, are included in the index count.

To change the order of sections, use the Move method.


Index Property Example

This example determines whether or not the active section is the first section in Binder1.obd. If it is, the example moves the first section after the third section.

Set myBinder = GetObject("Binder1.obd", "Office.Binder")

myBinder.Visible = True

If myBinder.ActiveSection.Index = 1 Then

myBinder.ActiveSection.Move after:=3

End If


Item Property

Accessor. Returns a Section object from the Sections collection object. Read-only.

Syntax

object.Item(index)

object

Required. The Sections object.

index

Required. The name or number of the section.

Remarks

Because the Item property is the default property of the Sections collection object, the following statements are identical:

myBinder.Sections.Item(3)

myBinder.Sections(3)


Item Property Example

This example displays the name of the third section in Binder1.obd.

Set myBinder = GetObject("Binder1.obd", "Office.Binder")

sectionName = myBinder.Sections.Item(3).Name

Set myBinder = Nothing

MsgBox sectionName


LeftPane Property

True if the left pane of the Binder window is visible. The left pane, also called the Binder pane, includes the icons for all the sections in the binder. Read-write.


LeftPane Property Example

This example creates a new binder and makes it visible. The example then adds a section of type Excel.Sheet, hides the Binder pane, and saves the binder as Binder1.obd.

Set newBinder = CreateObject("Office.Binder")

newBinder.Visible = True

With newBinder

.Sections.Add Type:="Excel.Sheet"

.LeftPane = False

.SaveAs "Binder1.obd"

End With


Move Method

Moves a section to another location in the binder.

Syntax

object.Move(before, after)

object

Required. The Section object.

before

Optional. The section that this section will be moved before. You cannot specify before if you specify after.

after

Optional. The section that this section will be moved after. You cannot specify after if you specify before.

Remarks

If you omit before and after, the section is moved after the last section in the binder.


Move Method Example

This example determines whether or not the active section of Binder1.obd comes after the first section. If it does, the example moves the active section before the first section in the binder.

Set myBinder = GetObject("Binder1.obd", "Office.Binder")

myBinder.Visble = True

If myBinder.ActiveSection.Index <> 1 Then

myBinder.ActiveSection.Move before:=1

End If


Name Property

Returns or sets the name of the Binder or Section object, as shown in the following table. Read-write.

Object	Name
Binder	The filename of the binder, not including its path on disk. Read-only.
Section	The name of the section, as shown on the icon in the Binder pane. Read-write.


Name Property Example

This example sets the name of the active section in Binder1.obd to "Budget 95."

Set myBinder = GetObject("Binder1.obd", "Office.Binder")

mBinder.Visible = True

myBinder.ActiveSection.Name = "Budget 95"


Object Property

Returns the OLE Automation object associated with this section. Read-only.

Remarks

Use this property to access the contents of the section (for example, the value of cell A1 on a Microsoft Excel worksheet).


Object Property Example

This example displays the value of the cell named "GrandTotal" on worksheet one in the section "Revenue 96."

Set myBinder = GetObject("Binder1.obd", "Office.Binder")

myBinder.Visible = True

total = myBinder.Sections("Revenue 96").Object.Range("GrandTotal")

MsgBox "The grand total for 1996 is " & total


Parent Property

Accessor. Returns the parent object for the specified object. Read-only.


Parent Property Example

This example prompts the user for a binder to open. It then adds a section of type Excel.Sheet and inserts the path of the binder in cell A1 on that worksheet.

obd = InputBox("Specify the binder to open")

Set myBinder = GetObject(obd, "Office.Binder")

myBinder.Visible = True

Set newSection = myBinder.Sections.Add(type:="Excel.Sheet")

newSection.Object.Range("A1").Value = newSection.Parent.Path


Path Property

Returns the complete path of the binder (as a string), without including the name of the binder. Read-only.


Path Property Example

This example displays the complete path of Binder1.obd.

Set myBinder = GetObject("Binder1.obd", "Office.Binder")

MsgBox myBinder.Path & myBinder.Name

Set myBinder = Nothing


PrintOut Method

Prints every section, a subset of sections, or a single section in the binder.

Syntax 1

object.PrintOut(what, numbering, firstPage, sections, fileName, printerName, driverName, noPrinting)

Syntax 2

object.PrintOut

object

Required. The Binder object (Syntax 1) or the Section object (Syntax 2).

what

Required. The section or sections in the binder to print. One of bindPrintActiveSection, bindPrintVisibleSections, bindPrintSelectedSections, or bindPrintSectionSubset.

numbering

Optional. The page numbering scheme. Either bindConsecutivePages (default) or bindRestartEachSection.

firstPage

Optional. The number at which to start numbering pages. If omitted, numbering starts at 1.

sections

Optional. If what is bindPrintSectionSubset, this is a one-dimensional array of the indexes of the sections to print.

fileName

Optional. The name of the file where the printing will be redirected.

printerName

Optional. The name of the printer. If omitted, the default printer will be used.

driverName

Optional. The name of the printer driver. If omitted, the default driver will be used.

noPrinting

Optional. If True, printerName and driverName are set but no printing is performed. If False or omitted, printing is performed.

Remarks

You can print a single section by using Syntax 1 and specifying the index of the section for the sections argument, or by using one of the printing methods that the section type provides in its object model (accessed through the Object property).


PrintOut Method Example

This example prints all visible sections in Binder1.obd. The first page is numbered 10.

Set myBinder = GetObject("Binder1.obd", "Office.Binder")

myBinder.PrintOut what:=bindPrintVisibleSections, _

numbering:=bindConsecutivePages, firstPage:=10

Set myBinder = Nothing

This example prints the first and second sections and the section named "Expense Report" in Binder4.obd.

Set myBinder = GetObject("Binder4.obd", "Office.Binder")

myBinder.PrintOut what:=bindPrintSectionSubset, _

sections:=Array(1, 2, "Expense Report")

Set myBinder = Nothing


Save Method

Saves changes to the specified binder.

Syntax

object.Save

object

Required. The Binder object.

Remarks

If you use Save to save a new binder, an error occurs. The first time you save a new binder, use the SaveAs method.


Save Method Example

This example adds a section of type Excel.Sheet to Binder1.obd and then saves the binder.

Set myBinder = GetObject("Binder1.obd", "Office.Binder")

With myBinder

    .Visible = True

    .Sections.Add Type:="Excel.Sheet"

    .Save

End With


SaveAs Method

Saves changes to the binder or section in a different file. Returns True if the binder is saved; returns False if it isn't saved. If the binder isn't visible, an error occurs.

Syntax 1

object.SaveAs(fileName, saveOption)

Syntax 2

object.SaveAs(fileName)

object

Required. The Binder object (Syntax 1) or the Section object (Syntax 2).

fileName

Required for Section, optional for Binder. A string indicating the name of the file to save. You can include a full path; if you don't, the file is saved in the current folder.

saveOption

Optional. Specifies options for saving the specified binder, as shown in the following table.

Value	Meaning
bindFailIfFileExists	If fileName exists, an error occurs; fileName is required. Default.
bindOverwriteExisting	If fileName exists, SaveAs overwrites it; fileName is required.
bindDisplayDialog	Displays the Save As dialog box; fileName is optional. If the user closes the dialog box without saving, SaveAs returns False.
Remarks

Sections are saved as unique files without deleting the corresponding sections in the binder. If you want to delete a section from the binder, use the Delete method.


SaveAs Method Example

This example determines whether or not the first section of Binder1.obd is of type Excel.Sheet.5. If it is, the example saves it as the workbook Book1.xls.

Set myBinder = GetObject("Binder1.obd", "Office.Binder")

If myBinder.Sections(1).Type = "Excel.Sheet.5" Then

myBinder.Sections(1).SaveAs "MyBook1.xls"

End If

Set myBinder = Nothing

This example creates a new binder, makes it visible, and then prompts the user to save it as Binder1.obd.

Set newBinder = CreateObject("Office.Binder")

newBinder.Visible = True

newBinder.SaveAs fileName:="Binder1.obd", _

saveOption:=bindDisplayDialog


Sections Property

Accessor. Returns a Sections collection object that represents all the sections in a binder. Read-only.

Remarks

This property returns the entire Sections collection. Use the Item property to return a single member of the collection (a Section object) by specifying either the name of the section or the collection index (as a number).

Because the Item property is the default property of the Sections collection object, the following statements are identical:

myBinder.Sections.Item(3)

myBinder.Sections(3)


Sections Property Example

This example displays the number of Microsoft Excel sections in Binder1.obd.

Set myBinder = GetObject("Binder1.obd", "Office.Binder")

wk = 0

For Each s In myBinder.Sections

If s.Type = "Excel.Sheet.5" Then

wk = wk + 1

End If

Next

MsgBox "There are " & wk & " Microsoft Excel sections in this binder."

Set myBinder = Nothing

This example displays the name of the third section in Binder1.obd. It also displays the position of the section named "Financial Analysis."

Set myBinder = GetObject("Binder1.obd", "Office.Binder")

MsgBox myBinder.Sections(3).Name

MsgBox myBinder.Sections("Financial Analysis").Index

Set myBinder = Nothing


SelectedSectionNames Property

Returns or sets the array of selected section names. Read-write.

Remarks

When you set the SelectedSectionNames property, the first section named in the array becomes the active section. If the array contains the name of a section that doesn't exist, an error occurs.


SelectedSectionNames Property Example

This example selects the first three sections in Binder1.obd.

Set myBinder = GetObject("Binder1.obd", "Office.Binder")

myBinder.Visible = True

Dim s(1 to 3) As String

For x = 1 To 3

s(x) = myBinder.Sections(x).Name

Next

myBinder.SelectedSectionNames = s


Type Property

Returns a string containing the OLE long class name for the Section object. Read-only.

Remarks

OLE long class names are specified as appName.objectType.versionNumber (for example, "Word.Document.6"). For more information about available binder section types, see the Add method.


Type Property Example

This example displays the type of the first section in Binder1.obd.

Set myBinder = GetObject("Binder1.obd", "Office.Binder")

theType = myBinder.Sections(1).Type

Set myBinder = Nothing

MsgBox theType


Visible Property

True if the binder or section is visible. Read-write.

Remarks

When OLE Automation starts a Binder object, the Visible property is False. To make the binder visible, set the Visible property to True.

Hidden sections are included in the count of the Sections collection object.


Visible Property Example

This example opens Binder1.obd and makes it visible.

Set myBinder = GetObject("Binder1.obd", "Office.Binder")

myBinder.Visible = True


Section Object

Represents a section in a binder.

Accessors

The Section object is a member of the Sections collection. The Sections collection contains all the Section objects in the binder. Use the Add method to create a new section and add it to the collection.

To access a single member of the collection, use the Item property of the Sections object with the index number or name of the section as an argument. Because the Item property is the default property of the Sections collection object, the following statements are identical:

myBinder.Sections.Item(3)

myBinder.Sections(3)

The index number represents the order in which the sections are located in the Binder pane. Sections(1) is the first section; Sections(Sections.Count) is the last. Activating a section doesn't change its index number. All sections are included in the index count, even if they're hidden. The following example activates section one in the specified binder.

myBinder.Sections(1).Activate

Remarks

The Name property returns and sets the section name. The following example displays the name of section one in Binder1.obd.

Set myBinder = GetObject("Binder1.obd", "Office.Binder")

theName = myBinder.Sections(1).Name

Set myBinder = Nothing

MsgBox theName

Use the SaveAs method to save a copy of the section to a different file. The following example saves section one in Binder1.obd to a new Microsoft Excel workbook.

Set myBinder = GetObject("Binder1.obd", "Office.Binder")

If myBinder.Sections(1).Type = "Excel.Sheet.5" Then

myBinder.Sections(1).SaveAs "MyBook3.xls"

End If

The following example activates the section named "Sumsales" in the binder named "Annual Report."

Set myBinder = GetObject("C:\reports\Annual Report.obd", "Office.Binder")

myBinder.Visible = True

myBinder.Sections("Sumsales").Activate


Sections Collection Object

A collection of all the Section objects in the binder. The Sections collection object contains all the sections in the binder, whether they're visible or hidden.

Accessors

Use the Add method to create a new section or to add an existing file as a section. The following example adds a new empty Microsoft Excel workbook section to the active binder.

Set myBinder = CreateObject("Office.Binder")

myBinder.Sections.Add Type:="Excel.Sheet"

The following example opens an existing binder and adds the file Array.xls as a section of the binder.

Set myBinder = GetObject("Binder1.obd", "Office.Binder")

myBinder.Visible = True

myBinder.Sections.Add fileName:="MyBook1.xls"

Use the Sections property to access the entire collection at once. The following example displays the number of sections in Binder1.obd.

Set myBinder = GetObject("binder1.obd", "Office.Binder")

MsgBox "there are " & myBinder.Sections.Count & _

    " sections in this binder"

Set myBinder = Nothing

To access a single member of the collection, use the Item property of the Sections object with the index number or name of the section as an argument. Because the Item property is the default property of the Sections collection object, the following statements are identical:

myBinder.Sections.Item(3)

myBinder.Sections(3)


Binder Object

Represents a Microsoft Office binder. A binder is created or opened in Visual Basic as an OLE Automation object.

Accessors

Use the CreateObject function to create a new binder. The following example creates a new binder, makes it visible, and saves it as Mybind.obd.

Set myBinder = CreateObject("Office.Binder")

myBinder.Visible = True

myBinder.SaveAs filename := "Mybind.obd"

Use the Open method or the GetObject function to open an existing binder. The following example opens the previously created binder and makes it visible.

Set myBinder = GetObject("Mybind.obd", "Office.Binder")

myBinder.Visible = True

Remarks

When a binder is created or opened, it's hidden. Set the Visible property for the specified binder to True to display the binder.


Open Method

Opens either an existing binder or a new binder based on an existing binder template.

Syntax

object.Open(fileName, openAsTemplate)

object

Required. The Binder object.

fileName

Required. A string indicating the name of the file to open.

openAsTemplate

Optional. If True, the file is opened as a new binder based on the specified binder template. If False or omitted, the file is opened as a binder file.

Remarks

The preferred method for opening an existing binder is by using the GetObject function.

Use the Open method immediately after CreateObject; otherwise, an error will occur.


Open Method Example

This example opens Binder2.obd and adds a new Word document before the first section in the binder.

Set myBinder = CreateObject("Office.Binder")

With myBinder

    .Open "Binder1.obd"

    .Sections.Add Type:="Word.Document", before:=1

    .Visible = True

End With


Update Method

Saves changes made to the section.

Syntax

object.Update

object

Required. The Section object to update.

Remarks

Use this method to make sure changes are saved in the binder. See the example for more details.


Update Method Example

This example creates a new binder, adds a Microsoft Excel worksheet, places a value in the worksheet, and saves the change. Without the Update method, the worksheet change would be lost when the new section object is set to Nothing.

Set newBinder = CreateObject("Office.Binder")

Set newSection = newBinder.Sections.Add(Type:="Excel.Sheet")

newSection.Object.Range("a1").Value = 3.14159

newSection.Update

Set newSection = Nothing


BuiltinDocumentProperties Property

Returns a DocumentProperties collection object that represents all the built-in document properties for the specified binder. Read-only.

To use this property, you should establish a reference to the Microsoft Office 95 Object Library by using the References command (Tools menu).

Remarks

This property returns the entire collection of built-in document properties. Use the Item method to return a single member of the collection (a DocumentProperty object) by specifying either the name of the property or the collection index (as a number). For a list of valid built-in document property names, see the Item method.

Because the Item method is the default method for the DocumentProperties collection object, the following statements are identical:

BuiltinDocumentProperties.Item(1)

BuiltinDocumentProperties(1)

Use the CustomDocumentProperties property to return the collection of custom document properties.


BuiltinDocumentProperties Property Example

This example displays the name of the author of Binder1.obd.

Set nb = GetObject("binder1.obd", "office.binder")

MsgBox nb.BuiltinDocumentProperties("Author").Value

Set nb = Nothing


 CustomDocumentProperties Property

Returns a DocumentProperties collection object that represents all the custom document properties for the specified binder. Read-only.

To use this object, you should establish a reference to the Microsoft Office 95 Object Library by using the References command (Tools menu).

Remarks

This property returns the entire collection of custom document properties. Use the Item method to return a single member of the collection (a DocumentProperty object) by specifying either the name of the property or the collection index as a number.

Because the Item method is the default method for the DocumentProperties collection object, the following statements are identical:

CustomDocumentProperties.Item("Complete")

CustomDocumentProperties("Complete")

Use the BuiltinDocumentProperties property to return the collection of built-in document properties.


CustomDocumentProperties Property Example

This example adds a custom document property to Binder1.obd and then saves the binder.

Set nb = GetObject("binder1.obd", "office.binder")

nb.CustomDocumentProperties.Add Name:="complete", _

LinkToContent:=False, Type:=offPropertyTypeBoolean, Value:=False

nb.Save

Set nb = Nothing