Library tutorials & articles

Using OLE Automation in VB

Introduction

Many beginners start developing programs in VB. They hear about OLE, Automation, ActiveX, COM, etc. but they are not aware of all these technologies. If you are a beginner and you want to know more about OLE, then you should read this article. It will help you get started writing code using OLE automation capabilities.

In this program, we'll use Word object. We'll use two objects, one of the Word Application class and one of the Word Document class. We'll open the Word Application and a document, and then we'll let the user save the document via our application.

Comments

  1. 07 Oct 2004 at 06:35


    this is a great example of how to create a new document using OLE but how can I point to and open an existing document?  I want to edit the text that your example had me save.  

  2. 06 Aug 2004 at 08:23

    Works great!  However in your close_cmd button you must comment out the objapp.quit() because vb.net claims it's ambiguous (which is why i put the me.close in there).  Also, I read somewhere that we shouldn't use the unload command--I believe it was from Rollarshade, so I didn't.  Now--how would I load data into the Word document using a SQL Server?


    Code:

           If objDoc Is Nothing Then
               MsgBox("Application not running")
           Else
               Me.Close()
               'objApp.Quit()
               objDoc = Nothing
               objApp = Nothing
           End If


    Code:

    If objDoc Is Nothing Then
               Me.Close()
           Else
               MsgBox("Please close application first")
           End If

  3. 01 Jan 1999 at 00:00

    This thread is for discussions of Using OLE Automation in VB.

Leave a comment

Sign in or Join us (it's free).