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.
MORE INFORMATION
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.
REFERENCES
For more information, please see the following articles in the Microsoft Knowledge Base:
118817 Summary of Sample Applications on the ODK 1.0
108043 INFO: How VB Uses OLE Automation with Word Version 6.0
121736 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: kbhowto kb32bitonly kbprogramming KB153305