Activate Method

Activates a specified section in the binder.

Syntax

expression.Activate

expression   Required. An expression that returns a Section object.

Remarks

You can select several sections 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 in the binder.

Set myBinder = CreateObject("Binder1.Binder")

myBinder.Visible = True

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

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

myBinder.Sections(1).Activate


Add Method

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.


Add Method 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"


Copy Method

Copies the specified section to another location in the binder, and returns the copy as a Section object. The new copy will automatically be given the name of the original section, with a number in parentheses appended; the original section won't be moved or altered.

Syntax

expression.Copy(Before, After)

expression   Required. An expression that returns a Section object.

Before   Optional Variant. The name or number of the section that the object will be copied before. You cannot specify Before if you've specified After.

After   Optional Variant. The name or number of the section that the object will be copied after. You cannot specify After if you've specified Before.


Copy Method Example

This example determines whether the second section in Binder1.obd is a Microsoft Excel worksheet. If so, it will be copied after the section named "Totals."

Set myBinder = GetObject("C:\Binder1.obd", "OfficeBinder.Binder")

myBinder.Sections(2).Activate

With myBinder.ActiveSection

If .Type = "Excel.Sheet.8" Then

    .Copy After:="Totals"

End If

End With


Count Property

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

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("C:\Binder1.obd", "OfficeBinder.Binder")

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

    " sections in the binder named: " & myBinder.Name


Delete Method

Deletes the specified Section object.

Syntax

expression.Delete

expression   Required. An expression that returns a Section object.


Delete Method Example

This example deletes the section named "Sums" in Binder1.obd. The example references the section by name, but you can also reference the section by number. You can permanently delete the section only after you've saved the binder.

Set myBinder = GetObject("C:\Binder1.obd", "OfficeBinder.Binder")

With myBinder

   .Sections("Sums").Delete

   .Save

End With


Index Property

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

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 the active section is the first section in Binder1.obd. If it is, the example moves the first section and places it after the third section.

Set myBinder = GetObject("C:\Binder1.obd", "OfficeBinder.Binder")

myBinder.Visible = True

If myBinder.ActiveSection.Index = 1 Then

myBinder.ActiveSection.Move after:=3

End If


Item Property

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

Syntax

expression.Item(Index)

expression   Required. An expression that returns a Sections object.

Index   Required Variant. The name or number of the section.

Remarks

The Item property is the default property of the Sections collection. You can use Sections(index), where index represents the name or index number of the section, to return a single Section object. The index number represents the order in which the section is listed in the Binder pane. Sections(1) is the first document, and Sections(Sections.Count) is the last document.


Item Property Example

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

Set myBinder = GetObject("C:\Binder1.obd", "OfficeBinder.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 Boolean.

Remarks

If this property is False, the Binder pane of the binder isn't visible, but a button that you can use to display the Binder pane is available.


LeftPane Property Example

This example uses the Open method to open the binder Binder2.obd. The example adds a new Word document to the binder, and it makes Binder pane visible.

Set myBinder = CreateObject("Binder1.Binder")

With myBinder

    .Open "binder2.obd"

    .Visible = True

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

    .LeftPane = False

End With


Move Method

Moves the specified section to another location in the binder.

Syntax

expression.Move(Before, After)

expression   Required. An expression that returns a Section object.

Before   Optional Variant. The name or index number of the section that the object will be moved before. You cannot specify Before if you've specified After.

After   Optional Variant. The name or index number of the section that the object will be moved after. You cannot specify After if you've specified Before.


Move Method Example

This example moves all Microsoft Excel workbooks in Binder1.obd to the last sections in the binder.

Set myBinder = GetObject("C:\Binder1.obd", "OfficeBinder.Binder")

lastOne = myBinder.Sections.Count

For Each thing In myBinder.Sections

    If thing.Type = "Excel.Sheet.8" Then

        thing.Move after:=lastOne

    End If

Next


Name Property

Binder object: Returns the file name of the binder, not including its path. Read-only String.

Section object: Returns or sets the name of the section, as displayed on the icon in the Binder pane. Read/write String.

Remarks

Use the Path property to return the location and the file name of the binder.


Name Property Example

This example sets the name of the second section in Binder1.obd to "Budget 95" and then saves the changes to the binder.

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


Object Property

Returns the OLE object associated with the specified section. Read-only.

Remarks

Use this property to access the contents of the specified section (for example, the value of cell A1 on a Microsoft Excel worksheet) and all the objects, methods, and properties of the application that created the section.


Object Property Example

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

Set myBinder = GetObject("C:\Binder1.obd", "OfficeBinder.Binder")

myBinder.Visible = True

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

MsgBox "The grand total for 1996 is " & total


Parent Property

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


Parent Property Example

This example adds a new section to the front of Binder1.obd and sets the name of the section.

Set myBinder = GetObject("C:\Binder1.obd", "OfficeBinder.Binder")

Set newSection = myBinder.Sections.Add(Type:="Word.Document", _

    Before:=1)

newSection.Name = "Intro to " & newSection.Parent.Name


Path Property

Returns the complete path and file name of the specified binder. Read-only String.


Path Property Example

This example prompts the user for the name of a binder to open, and then it confirms the choice by displaying the path of the specified binder.

myBinder = InputBox("Type the name of the binder you want to open")

Set myBinder = GetObject(myBinder, "OfficeBinder.Binder")

MsgBox "The binder you specified is located in " _

    & myBinder.Path


PrintOut Method

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

Syntax 1

expression.PrintOut(What, Numbering, FirstPage, Sections, FileName, PrinterName, DriverName, NoPrinting)

Syntax 2

expression.PrintOut

expression   Required. An expression that returns a Binder object (Syntax 1) or a Section object (Syntax 2).

What   Required Variant. The section or sections to be printed. Can be one of the following BindPrintWhat constants: bindPrintActiveSection, bindPrintVisibleSections, bindPrintSelectedSections, or bindPrintSectionSubset.

Numbering   Optional Variant. The page numbering scheme. Can be either of the followoing BindPrintNumbering constants: bindConsecutivePages or bindRestartEachSection. The default value is bindConsecutivepages.

FirstPage   Optional Variant. The first page number. If this argument is omitted, page numbering starts at 1.

Sections   Optional Variant. If What is bindPrintSectionSubset, this argument is a one-dimensional array of the indexes of the sections to be printed. You can specify the index number to print one section or a one-dimensional array of indexes to print multiple sections.

FileName   Optional Variant. The name of the file to which the printing will be redirected.

PrinterName   Optional Variant. The name of the printer to be used. If this argument is omitted, the default printer is used.

DriverName   Optional Variant. The name of the printer driver to be used. If this argument is omitted, the default driver is used.

NoPrinting   Optional Variant. True to set PrinterName and DriverName but not print anything. False (or omitted) to print the specified section or sections.

Remarks

You can print a single section by using Syntax 1 and specifying the index number 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("C:\Binder1.obd", "OfficeBinder.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", "OfficeBinder.Binder")

myBinder.PrintOut what:=bindPrintSectionSubset, _

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

Set myBinder = Nothing


Save Method

Saves changes to the specified binder. Use this method only for binders that have been previously saved.

Syntax

expression.Save

expression   Required. An expression that returns a Binder object.

Remarks

If you use the Save method 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 sets the name of the second section in Binder1.obd to "Budget 95" and then saves the changes to the binder.

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


SaveAs Method

Saves changes to the specified binder or section to a different file. Use this method only for visible binders, or for newly created binders that haven't yet been saved. Returns True if the binder is saved or False if an error occurs and the binder cannot be saved.

Syntax 1

expression.SaveAs(FileName, SaveOption)

Syntax 2

expression.SaveAs(FileName)

expression   Required. An expression that returns a Binder object (Syntax 1) or a Section object (Syntax 2).

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

SaveOption   Optional Variant. Specifies the way the specified binder is saved. Can be one of the following BindSaveOption constants.

Constant	Description
bindFailIfFileExists	If FileName exists, an error occurs (FileName must be specified). This constant is the default value.
bindOverwriteExisting	If FileName exists, SaveAs overwrites it (FileName must be specified).
bindDisplayDialog	Displays the Save As dialog box (FileName is optional). If the user closes the Save As dialog box without saving, SaveAs returns False.
Remarks

The SaveAs method saves sections 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 the first section in Binder1.obd is of type Excel.Sheet.8. If it is, the example saves it as the workbook Book1.xls.

Set myBinder = GetObject("C:\Binder1.obd", "OfficeBinder.Binder")

If myBinder.Sections(1).Type = "Excel.Sheet.8" 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("OfficeBinder.Binder")

newBinder.Visible = True

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

saveOption:=bindDisplayDialog


Sections Property

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

For information about returning a single member of a collection, see Returning an Object from a Collection.


Sections Property Example

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

Set myBinder = GetObject("C:\Binder1.obd", "OfficeBinder.Binder")

wk = 0

For Each s In myBinder.Sections

If s.Type = "Excel.Sheet.8" 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.

Set myBinder = GetObject("C:\Binder1.obd", "OfficeBinder.Binder")

MsgBox myBinder.Sections(3).Name

Set myBinder = Nothing


SelectedSectionNames Property

Returns or sets the array that contains the names of the selected sections. Read/-write Variant.

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 displays the names of the selected sections in Binder1.obd.

Set myBinder = GetObject("C:\Binder1.obd", "OfficeBinder.Binder")

With myBinder

myarray = .SelectedSectionNames

MsgBox UBound(myarray) & " section is selected."

For x = 1 To UBound(myarray)

    MsgBox "The section name is " & myarray(x)

Next

End With


Type Property

Returns a string that contains the OLE long class name for the Section object. Read-only String.

Remarks

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


Type Property Example

This example moves all Microsoft Excel workbooks in the binder Binder1.obd to the last sections in the binder.

Set myBinder = GetObject("C:\Binder1.obd", "OfficeBinder.Binder")

lastOne = myBinder.Sections.Count

For Each thing In myBinder.Sections

    If thing.Type = "Excel.Sheet.8" Then

        thing.Move after:=lastOne

    End If

Next


Visible Property

True if the specified binder or section is visible. Read/write Boolean.

Remarks

When a Binder object is created by the CreateObject function or opened by the GetObject function, the Visible property is False. To make the binder visible, set the Visible property to True.

Hidden sections are included in the count for the Sections collection.


Visible Property Example

This example opens Binder1.obd and makes it visible.

Set myBinder = GetObject("C:\Binder1.obd", "OfficeBinder.Binder")

myBinder.Visible = True


Open Method

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

Note   The preferred method for opening an existing binder is to use the GetObject function, and then to use the Visible method if you want to display the binder to the user. If you use the Open method instead of the GetObject function, use the Open method immediately after using CreateObject; otherwise, an error will occur.

Syntax

expression.Open(FileName, OpenAsTemplate)

expression   Required. An expression that returns a Binder object.

FileName   Required String. The name of the file to be opened.

OpenAsTemplate   Optional Variant. True to open the file as a new binder based on the specified binder template. False (or omitted) to open the file as a binder file.


Open Method Example

This example opens Binder2.obd. The example adds a new Word document to the binder and then makes the binder visible.

Set myBinder = CreateObject("OfficeBinder.Binder")

With myBinder

    .Open "binder2.obd"

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

    .Visible = True

End With


Update Method

Updates the specified section, but doesn't save changes made to the binder. Use the Save method to save changes to the binder.

Syntax

expression.Update

expression   Required. An expression that returns a Section object.

Remarks

The Update method is useful if several sections need to be updated before the binder is saved.


Update Method Example

This example adds a Microsoft Excel worksheet to an existing binder, inserts a value in the worksheet, and updates the new section. Without the Update method, the change would be lost when the new Section object is set to Nothing. (Use the Save method to permanently save these changes to the binder.)

Set newBinder = GetObject("C:\Binder1.obd", "OfficeBinder.Binder")

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

With newSection

    .Object.Worksheets(1).Range("a1").Value = 3.14159

    .Update

End With

Set newSection = Nothing


Formatting Codes for Headers and Footers

The special formatting codes listed in the following table can be used with the header and footer properties (LeftHeader property, CenterHeader property, RightHeader property, LeftFooter property, CenterFooter property, and RightFooter property).

Format code	Description
&L	Left aligns the characters that follow.
&C	Centers the characters that follow.
&R	Right aligns the characters that follow.
&E	Turns double-underline printing on or off.
&X	Turns superscript printing on or off.
&Y	Turns subscript printing on or off.
&B	Turns bold printing on or off.
&I	Turns italic printing on or off.
&U	Turns underline printing on or off.
&S	Turns strikethrough printing on or off.
&O	Prints the section number.
&H	Prints the total number of sections.
&D	Prints the current date.
&T	Prints the current time.
&F	Prints the name of the document.
&A	Prints the name of the section.
&P	Prints the page number.
&P+number	Prints the page number plus number.
&P-number	Prints the page number minus number.
&&	Prints a single ampersand.
& "fontname"	Prints the characters that follow in the specified font. Be sure to include the double quotation marks.
&nn	Prints the characters that follow in the specified font size. Use a two-digit number to specify a size in points.
&N	Prints the total number of pages in the document.
&K	Prints the user name as a static text string.
&M	Prints the company name as a static text string.


CenterFooter Property

Returns or sets the center part of the footer in sections that support headers or footers (or both) and that are included in the binder at the time the footer is set. Read/write String.

Remarks

You can use special format codes in the footer text.


CenterFooter Property Example

This example prints the page number — in bold, italic type — in the center of every page in each section of Binder1.obd that supports headers or footers (or both).

Set myBinder = GetObject("C:\Binder1.obd", "OfficeBinder.Binder")

With myBinder

For Each s In .Sections

    If s.SupportsBinderHeaderFooter Then

        .PageSetup.CenterFooter = "&B &I &P &B"

        s.HasBinderHeaderFooter = True

    End If

Next

.Close SaveChanges:=True

End With


CenterHeader Property

Returns or sets the center part of the header in sections that support headers or footers (or both) and that are included in the binder at the time the header is set. Read/write String.

Remarks

You can use special format codes in the header text.


CenterHeader Property Example

This example prints the date and the time, in bold type, at the center of each page in every section of Binder1.obd that supports headers or footers (or both).

Set myBinder = GetObject("c:\Binder1.obd", "OfficeBinder.Binder")

With myBinder

For Each s In .Sections

    If s.SupportsBinderHeaderFooter Then

        .PageSetup.CenterHeader = "&B &D &T &B"

        s.HasBinderHeaderFooter = True

    End If

Next

.Close SaveChanges:=True

End With


FirstPage Property

Returns or sets the number of the first page in a section that supports headers or footers (or both). Read/write Long.

Remarks

When a binder is first created, this property is set to 1. Use this property if you want to set the number of the first page to something other than 1.


FirstPage Property Example

This example prints the first section of Binder1.obd, and it starts the page numbering at 100. The page number will be printed as a right-aligned footer in the first section, if it supports headers or footers (or both).

Set myBinder = GetObject("C:\Binder1.obd", "OfficeBinder.Binder")

With myBinder

If .Sections(1).SupportsBinderHeaderFooter Then

    With .PageSetup

        .FirstPage = 100

        .RightFooter = "&P"

        .PrintWhat = bindPageSetupSelectedSections

     End With

End If

.Close SaveChanges:=True

End With


LeftFooter Property

Returns or sets the left-aligned part of the footer in sections that support headers or footers (or both) and that are included in the binder at the time the footer is set. Read/write String.

Remarks

You can use special format codes  in the footer text.


LeftFooter Property Example

This example prints the page number — in bold, italic type — in the lower-left corner of each page in every section of Binder1.obd that supports headers or footers (or both).

Set myBinder = GetObject("C:\Binder1.obd", "OfficeBinder.Binder")

With myBinder

For Each s In .Sections

    If s.SupportsBinderHeaderFooter Then

        s.PageSetup.LeftFooter = "&B &I &P &B"

        s.HasBinderHeaderFooter = True

    End If

Next

.Close SaveChanges:=True

End With


LeftHeader Property

Returns or sets the left-aligned part of the header in sections that support headers or footers (or both) and that are included in the binder at the time the header is set. Read/write String.

Remarks

You can use special format codes in the header text.


LeftHeader Property Example

This example prints the date and the time, in bold type, in the upper-left corner of each page in every section of Binder1.obd that supports headers aor footers (or both).

Set myBinder = GetObject("C:\Binder1.obd", "OfficeBinder.Binder")

With myBinder

For Each s In .Sections

    If s.SupportsBinderHeaderFooter Then

        .PageSetup.LeftHeader = "&B &D &T &B"

        s.HasBinderHeaderFooter = True

    End If

Next

.Close SaveChanges:=True

End With


Numbering Property

Returns or sets the type of numbering that the sections of the specified binder will contain. Can be either of the following BindPrintNumbering constants: bindConsecutivePages or bindRestartEachSection. Read/write Variant.


Numbering Property Example

This example places the page number in the lower-left corner of each page in Binder1.obd, and it restarts the page numbering at the beginning of each section in the binder.

Set myBinder = GetObject("C:\Binder1.obd", "OfficeBinder.Binder")

With myBinder.PageSetup

    .LeftFooter = "&P"

    .Numbering = bindRestartEachSection

End With


PrintWhat Property

Returns or sets the sections of the specified binder that will be printed. Can be either of the following BindPageSetupPrintWhat constants: bindPageSetupSelectedSections or bindPageSetupVisibleSections. Read/write Variant.


PrintWhat Property Example

This example places the date and the time in the upper-left corner of each page in Binder1.obd, and it sets all the visible sections of the binder that support headers or footers (or both) to print.

Set myBinder = GetObject("C:\Binder1.obd", "OfficeBinder.Binder")

With myBinder

For Each s In .Sections

    If s.SupportsBinderHeaderFooter Then

        .PageSetup.LeftHeader = "&D &T"

        .PageSetup.PrintWhat = bindPageSetupVisibleSections

        s.HasBinderHeaderFooter = True

    End If

Next

.Close SaveChanges:=True

End With


RightFooter Property

Returns or sets the right-aligned part of the footer in sections that support headers or footers (or both) and that are included in the binder at the time the footer is set. Read/write String.

Remarks

You can use special format codes in the footer text.


RightFooter Property Example

This example prints the page number — in bold, italic type — in the lower-right corner of each page in every section of Binder1.obd that supports headers or footers (or both).

Set myBinder = GetObject("C:\Binder1.obd", "OfficeBinder.Binder")

With myBinder

For Each s In .Sections

    If s.SupportsBinderHeaderFooter Then

        .PageSetup.RightFooter = "&B &I &P &B"

        s.HasBinderHeaderFooter = True

    End If

Next

.Close SaveChanges:=True

End With


RightHeader Property

Returns or sets the right-aligned part of the header in sections of the specified binder that support headers or footers (or both) and that are included in the binder at the time the header is set. Read/write String.

Remarks

You can use special format codes in the header text.


RightHeader Property Example

This example prints the date and the time, in bold type, in the upper-right corner of each page in every section of Binder1.obd that support headers or footers (or both).

Set myBinder = GetObject("C:\Binder1.obd", "OfficeBinder.Binder")

With myBinder

For Each s In .Sections

    If s.SupportsBinderHeaderFooter Then

        .PageSetup.LeftHeader = "&B &D &T &B"

        s.HasBinderHeaderFooter = True

    End If

Next

.Close SaveChanges:=True

End With


Close Method

Closes the specified binder.

Syntax

expression.Close(SaveChanges, FileName)

expression   Required. An expression that returns a Binder object.

SaveChanges   Optional Variant. True to save changes to the binder. False to save the binder without saving changes. If this argument is omitted and there are changes to the binder, a dialog box is displayed asking the user whether to save changes. If there are no changes, this argument is ignored.

FileName   Optional Variant. The name you want to give the binder when you save it, if it hasn't been previously saved. If this argument is omitted and the binder hasn't been saved at least once, the Save As dialog is displayed. If the binder has already been saved, this argument is ignored.


Close Method Example

This example closes the binder represented by newBinder and saves it as NewBinder2.obd.

newBinder.Close _

SaveChanges:=True,FileName:="NewBinder2.obd"


DefaultFilePath Property

Returns or sets the default path that Microsoft Office Binder uses when it either opens files or saves them. Read/write String.

Remarks

The default path after installation of Microsoft Office is C:\My Documents.


DefaultFilePath Property Example

This example displays the current default file path.

MsgBox "The current default file path is " & _

newBinder.DefaultFilePath


DisplayAlerts Property

True if Microsoft Office Binder displays certain alerts and messages when the specified binder is active. Read/write Boolean.


DisplayAlerts Property Example

This example closes the binder represented by newBinder, without prompting the user to save changes. Changes to the binder aren't saved.

newBinder.DisplayAlerts = False

newBinder.Close


ExitOpenMode Method

Closes the host application and returns to Microsoft Office Binder.

Syntax

expression.ExitOpenMode

expression   Required. An expression that returns a Binder object.


ExitOpenMode Method Example

This example adds a new Microsoft Excel workbook to the binder and opens the new section in the host application (Microsoft Excel).  It adds the number 45 to a range in a worksheet and then closes the host application and saves the new binder file.

Set newbinder = GetObject("C:\Binder2.obd", _

"Office.Binder")

newbinder.ViewOpenMode

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

With newSection

    .Object.Worksheets(1).Range("a1").Value = 45

End With

newbinder.ExitOpenMode

newbinder.Close _

savechanges:=True, FileName:="changed.obd"


DisplayLeftPaneAndButton Property

True if the left pane (also known as the Binder pane) of the specified binder and the button that allows the user to display this pane are visible. Read/write Boolean.


DisplayLeftPaneAndButton Property Example

This example displays the binder represented by newBinder but doesn't display the Binder pane. The button that allows the user to display this pane isn't available.

newBinder.DisplayLeftPaneAndButton = False

newBinder.Visible = True


PageSetup Property

Returns a PageSetup object that represents the page setup description. Read-only.


PageSetup Property Example

This example prints the page number — in bold, italic print — in the center of each page in the binder represented by myBinder.

Set myBinder = GetObject("C:\Binder1.obd", "OfficeBinder.Binder")

myBinder.PageSetup.CenterFooter = "&B &I &P &B"


SinglePrintJob Property

True if all the sections in the binder are printed together, as a unit. False if each section in the binder will be printed as a separate job. Read/write Boolean.


SinglePrintJob Property Example

This example opens a Binder file and prints it as a single print job.

Set newbinder = GetObject("C:\Binder2.obd", _

"Office.Binder")

With newbinder

    .SinglePrintJob = True

    .PrintOut what:=bindPrintVisibleSections, _

    Numbering:=bindConsecutivePages

    .Close _

    SaveChanges:=True, FileName:="changed.obd"

End With


ViewOpenMode Method

Displays the active section of the specified binder within the section's host application.

Syntax

expression.ViewOpenMode

expression   Required. An expression that returns a Binder object.

Remarks

If the host application isn't available or isn't installed, an error will occur.


ViewOpenMode Method Example

This example adds a new Microsoft Excel workbook to the binder and opens the new section in the host application (Microsoft Excel).  It adds the number 45 to a range in a worksheet and then closes the host application and saves the new binder file.

Set newbinder = GetObject("C:\Binder2.obd", _

"Office.Binder")

newbinder.ViewOpenMode

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

With newSection

    .Object.Worksheets(1).Range("a1").Value = 45

End With

newbinder.ExitOpenMode

newbinder.Close _

savechanges:=True, FileName:="changed.obd"


DisplayStatusBar Property

True if Microsoft Office Binder displays a status bar at the bottom of the application window. Read/write Boolean.


DisplayStatusBar Property Example

This example opens Binder2.obd, displays the status bar, and makes the binder visible.

Set newb = GetObject("C:\Binder2.obd", "Office.Binder")

newb.DisplayStatusBar = True

newb.Visible = True


ActiveSection Property

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 Binder2.obd, activates the first section, and creates a copy of the active section, if the active section is an Excel chart. The new section is renamed "Copy of Section 1."

Set newBinder = GetObject("C:\Binder2.obd", _

    "Office.Binder")

With newBinder

    .Visible = True

    .Sections(1).Activate

    If .ActiveSection.Type = "Excel.Chart.8" Then

        .ActiveSection.Copy

        .ActiveSection.Name = "Copy of Section 1"

    End If

End With


HasBinderHeaderFooter Property

True if the specified binder section contains a printable header or footer. Read/write Boolean.


HasBinderHeaderFooter Property Example

This example prints the page number — in bold, italic type — in the center of every page in each section of Binder1.obd that supports headers or footers (or both).

Set myBinder = GetObject("C:\Binder1.obd", _

    "OfficeBinder.Binder")

With myBinder

For Each s In .Sections

    If s.SupportsBinderHeaderFooter Then

        .PageSetup.CenterFooter = "&B &I &P &B"

        s.HasBinderHeaderFooter = True

    End If

Next

.Close SaveChanges:=True

End With


SupportsBinderHeaderFooter Property

True if the specified binder section supports headers or footers. Read-only Boolean.


SupportsBinderHeaderFooter Property Example

This example prints the page number — in bold, italic type — in the center of every page in each section of Binder1.obd that supports headers or footers (or both).

Set myBinder = GetObject("C:\Binder1.obd", _

    "OfficeBinder.Binder")

With myBinder

For Each s In .Sections

    If s.SupportsBinderHeaderFooter Then

        .PageSetup.CenterFooter = "&B &I &P &B"

        s.HasBinderHeaderFooter = True

    End If

Next

.Close SaveChanges:=True

End With


Section Object

Represents a section (a specific document) in a binder. For example, if a binder contains a Microsoft Excel spreadsheet, two Word documents, and a PowerPoint presentation, the binder contains four sections. The Section object is a member of the Sections collection.

Using the Section Object

Use Sections(index), where index is the number of the section you want to return, to return a single Section object. The index number represents the order in which the sections are listed in the Binder pane. Sections(1) is the first document, and Sections(Sections.Count) is the last document.

Activating a section opens the document in place; it doesn't change the document's index number. All sections are included in the index count, even sections that are hidden. The following example activates the first document in the binder represented by myBinder.

myBinder.Sections(1).Activate

Remarks

The Name property returns or sets the name of the specified section. The following example displays the name of the first section in Binder1.obd.

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

theName = myBinder.Sections(1).Name

Set myBinder = Nothing

MsgBox theName

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

Set myBinder = GetObject("C:\Binder1.obd", "OfficeBinder.Binder")

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

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

End If

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

Set myBinder = GetObject("C:\reports\Annual Report.obd", _

"OfficeBinder.Binder")

myBinder.Visible = True

myBinder.Sections("Sumsales").Activate


Sections Collection Object

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


Binder Object

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

Using the Binder Object

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

Set myBinder = CreateObject("OfficeBinder.Binder")

myBinder.Visible = True

myBinder.SaveAs Filename := "Mybind.obd"

Use 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", "OfficeBinder.Binder")

myBinder.Visible = True

Remarks

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


PageSetup Object

Represents the page setup description. The PageSetup object contains all the page setup attributes (left footer, center header, numbering, and so on) as properties.

Using the PageSetup Object

Use the PageSetup property to return the PageSetup object. This example prints the visible sections of the binder, and and it starts the page numbering at 100. The page numbers are printed as right-aligned footers.

Set myBinder = GetObject("C:\Binder1.obd", "OfficeBinder.Binder")

With myBinder.PageSetup

    .FirstPage = 100

    .RightFooter = "&P"

    .PrintWhat = bindPrintVisibleSections

End With

Remarks

To print a header or footer in a section, the section must first be capable of supporting printed headers or footers (or both), and it must contain a printable header or footer. Use the SupportsBinderHeaderFooter property to determine whether the section supports headers or footers. Use the HasBinderHeaderFooter to determine whether the section contains a printable header or footer. The following example sets the page number, in bold type, in the center of each page in every section of MyBinder.doc that supports headers or footers, and then it prints all visible sections of the binder.

Set myBinder = GetObject("c:\Binder1.obd", "OfficeBinder.Binder")

With myBinder

For Each s In .Sections

    If s.SupportsBinderHeaderFooter Then

        .PageSetup.CenterFooter = "&B &P &B"

        s.HasBinderHeaderFooter = True

    End If

Next

myBinder.PrintOut What:=bindPrintVisibleSections

.Close SaveChanges:=True

End With


BuiltinDocumentProperties Property

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

Remarks

Use the CustomDocumentProperties property to return the DocumentProperties collection that represents all the custom document properties for the specified binder.


BuiltinDocumentProperties Property Example

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

Set nb = GetObject("C:\Binder1.obd", "OfficeBinder.Binder")

MsgBox nb.BuiltinDocumentProperties("Author").Value

Set nb = Nothing


CustomDocumentProperties Property

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

Remarks

Use the BuiltinDocumentProperties property to return the DocumentProperties collection that represents all the built-in document properties for the specified binder.


CustomDocumentProperties Property Example

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

Set nb = GetObject("C:\Binder1.obd", "OfficeBinder.Binder")

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

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

nb.Save

Set nb = Nothing


Microsoft Office Binder Objects


OLE Programmatic Identifiers (Microsoft Office Binder)

You use an OLE programmatic identifier (sometimes called a ProgID) to create an Automation object.

To create an Automation object that represents a Microsoft Office Binder Binder object, use "OfficeBinder.Binder.8." Using "OfficeBinder.Binder" with no version number creates a binder in the most recent version of Microsoft Office Binder available on the machine where the macro is running.


Returning an Object from a Collection

The Item property returns a single object from a collection. The following example sets the mySection variable to a Section object that represents the first section in a binder. The variable myBinder is set to an existing binder file.

Set mySection = myBinder.Sections.Item(1)

The Item property is the default property of the Sections collection, so you can write the same statement more concisly by omitting the Item keyword.

Set mySection = myBinder.Sections(1)


Help Topic Not Available

The Help topic cannot be displayed because Visual Basic for Applications Help cannot be found or was not installed.

To install Visual Basic for Applications Help

1.	Run Microsoft Office 97 Setup, and click Add/Remove.

1.	Click Microsoft Excel, Microsoft PowerPoint, or Microsoft Word, and then click Change Option.

1.	Click Help, and then click Change Option.

2.	Make sure that the Help for Visual Basic check box is selected.

3.	Continue with Setup.


Help Topic Not Available

The Help topic cannot be displayed because Microsoft Office Visual Basic Help cannot be found or was not installed.

To install Visual Basic for Applications Help

1.	Run Microsoft Office 97 Setup, and click Add/Remove.

1.	Click Microsoft Excel, Microsoft PowerPoint, or Microsoft Word, and then click Change Option.

1.	Click Help, and then click Change Option.

2.	Make sure that the Help for Visual Basic check box is selected.

3.	Continue with Setup.