ID: Q153305
The information in this article applies to:
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.
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.
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 : kbprg kbVBp400 VB4WIN vbwin kb32bitOnly
Version : WINDOWS:4.0
Platform : NT WINDOWS
Issue type : kbhowto
Last Reviewed: October 2, 1997