Microsoft KB Archive/153305

= How To Automate the Microsoft Office Binder Object through OLE =

Article ID: 153305

Article Last Modified on 1/25/2005

-

APPLIES TO


 * Microsoft Visual Basic 4.0 Standard Edition
 * Microsoft Visual Basic 4.0 Professional Edition
 * Microsoft Visual Basic 4.0 Professional Edition
 * Microsoft Visual Basic 4.0 16-bit Enterprise Edition
 * Microsoft Visual Basic 4.0 32-Bit Enterprise Edition

-



This article was previously published under Q153305



SUMMARY
As part of Microsoft Office 95, a new application called Office Binder was shipped to help manage documents created using the Microsoft Office products. The Office Binder packages documents from different Office applications. This article provides a code sample showing how to manipulate the Office Binder programmatically through OLE Automation from Visual Basic.



Step-by-Step Example
 Start a new project in Visual Basic. Form1 is created by default. Place a CommandButton on Form1. On the Tools References menu, click the Office Binder Type Library.  Add the following code to the General Declarations section of Form1: Option Explicit

Private Sub Command1_Click Dim objBinder As Object Dim objWord As Object Set objBinder = CreateObject("Office.Binder") objBinder.Visible = True Set objWord = CreateObject("Word.Basic") With objWord .FileNewDefault .FormatStyle Name:="Heading 1", Apply:=True .Insert "OLE Automation to Office Binder" .InsertPara .FileSaveAs "c:\ole_test.DOC" .FileClose End With Set objWord = Nothing With objBinder .Sections.Add filename:="c:\ole_test.doc" .Sections(1).Name = "Ole Sample from VB" .SaveAs filename:="c:\vbNewBinder.obd", _ saveOption:=bindOverwriteExisting .Visible = False End With Set objBinder = Nothing End Sub  Run the project, and click the CommandButton. The Microsoft Word document and Microsoft Office binder files are created on the root of the C: drive. You could just as easily create an object for Microsoft Excel, Microsoft Project, or Microsoft PowerPoint, and save the files into the Binder object in exactly the same way.

