HOWTO: Automate the Microsoft Office Binder Object through OLE

ID: Q153305


The information in this article applies to:
  • Microsoft Visual Basic Standard, Professional, and Enterprise Editions, 16-bit and 32-bit, for Windows, 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:


  5. 
    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 
  6. 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.


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

Q118817 Summary of Sample Applications on the ODK 1.0
Q108043 INFO: How VB Uses OLE Automation with Word Version 6.0
Q121736 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.

Additional query words:

Keywords : kbprg kbVBp400 kbDSupport VB4WIN vbwin kb32bitOnly
Version : WINDOWS:4.0
Platform : WINDOWS
Issue type : kbhowto


Last Reviewed: October 12, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.