HOWTO: Automate the Microsoft Office Binder Object through OLE

Last reviewed: September 30, 1997
Article ID: Q153305
The information in this article applies to:
  • Standard, Professional, and Enterprise Editions of Microsoft Visual Basic for Windows, 16-bit and 32-bit, version 4.0

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.

MORE INFORMATION

Step-by-Step Example

  1. Start a new project in Visual Basic. Form1 is created by default.

  2. Place a CommandButton on Form1.

  3. On the Tools References menu, click the Office Binder Type Library.

  4. 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
    
    

  5. Run the project, and click the CommandButton. The Microsoft Word document and Microsoft Office binder files will be 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.

REFERENCES

For more information, please see the following articles in the Microsoft Knowledge Base:

   ARTICLE-ID: Q118817
   TITLE     : Summary of Sample Applications on the ODK 1.0

   ARTICLE-ID: Q108043
   TITLE     : INFO: How VB Uses OLE Automation with Word Version 6.0

   ARTICLE-ID: Q121736
   TITLE     : Getting OLE Automation Methods/Properties Supported by OLE
               App

Chapter 9 of the Programmer's Guide gives a good overview of interacting with other applications through OLE from Visual Basic

The Office Developer's Kit has a lot of OLE Sample code.

Keywords          : vb432 VB4WIN vbwin GnrlVb kbprg
Technology        : kbvba
Version           : WINDOWS:4.0
Platform          : NT WINDOWS
Issue type        : kbhowto


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: September 30, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.