1. Home
  2. Computing & Technology
  3. Visual Basic
VBA - Word and Excel Working Together
Part 6: The Final Result
 More of this Feature
• Part 1: Word and Excel Working Together
• Part 2: Designing the System
• Part 3: The Word Document VBA Code
• Part 4: The Word Form
• Part 5: VBA Code Calling the Excel Server
 
 Join the Discussion
Have you created a system using VBA Automation ?
Tell us about it!
 
 Related Resources
• Beginning Visual Basic
• Visual Basic 6
 
 From Other Guides
• About Business Software
 
 Elsewhere on the Web
• An Excel VBA book
From the great publisher, APress

• Updates from Microsoft
(Browse to Office 2000)

 

Here's what the final result looks like (to keep the image small, I reduced the margins and paper size):

Completed Word Document

Two general concepts are worth mentioning now that we've seen how this works.

The first is a peek forward toward VB .NET. The idea of using objects to build programs is virtually the whole ball game in VB .NET. So learning about it here is a great way to get ready. But at the same time, VB .NET streamlines the way they work. For example, in VB 6, you use the Set statement to handle objects but this isn't necessary in VB .NET since EVERYTHING is an object.

The second is a peek backward at previous Microsoft technology, specifically something called DDE (Dynamic Data Exchange). This is an non-object oriented but alternative way to accomplish many of the same things. If you have a book about VBA for Office, you might get confused reading about initiating DDE channels and how it differs from OLE Automation (Object Linking and Embedding - Microsoft's terminology for what we're doing in this example at that time). The problem was that software took a few years to be upgraded to the new object oriented way of doing things and a lot of it wouldn't work using the techniques shown here. (Something that will happen again as we move to .NET!) My advice: DDE is now so old and outdated that you probably should either upgrade to software that at least supports Automation, or reconsider even trying to write any new system using VBA. The only excuse for DDE today is maintenance of old systems that already use it.

The terms client and server are also used in VBA Automation. The client uses information and the server provides it. In this simple example, Word is the client and Excel is the server.

Download the application and give it a try! Remember to change the {path} to match your own directory structure, and remember that this is just a "starter" application. Use the ideas here to build a real one of your own!

First page > Word and Excel Working Together > Page 1, 2, 3, 4 5, 6

Explore Visual Basic

More from About.com

  1. Home
  2. Computing & Technology
  3. Visual Basic

©2008 About.com, a part of The New York Times Company.

All rights reserved.