Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Using Visual C++ .NET to build a program integrated with Microsoft Visual Basic for Application (VBA)

0.00/5 (No votes)
4 Dec 2002 1  
Create a MFC Program which integrates with Microsoft Visual Basic for Application.

Introduction

One of the key features of some famous commercial software (such as Microsoft Office, AutoCAD 2002 etc.) is Microsoft Visual Basic for Application (VBA) integrated. Based on VBA, such kind of software become development platforms we know well. In this article, I would introduce to you how to create software integrated with Microsoft VBA and how to use components coming from ActiveX controls, COM, Visual C++, .NET and Delphi/C++ Builder etc. to compose complex interface layout in your ways in such software, and how to map each object to a VBA object.

How to create a program integrated with Microsoft VBA?

  • You need to install Tangram SDK (You can get it free from here).
  • After installing, you can use wizard to create a MFC project.
    • Select wizard �Tangram Application 2�.
    • Select all options in Tangram option pane of the next page.

      Sample Image - TangramDev.jpg

    • Compile and Run this program.

Sample Image - TangramDev.jpg

How to use this program to design a frame window?

Create a new document. You will see the word "DESIGN" in the new document. Click it, fill 1 in row, and 2 in columns in the splitter tab pane and create it. Repeat the operation above in the right splitter tab pane, fill 2 in rows and 1 in columns. Then you will see the figure below.

Add components.

The figure below is a frame window having included different components created by different languages.

Sample Image - TangramDev.jpg

The left splitter pane is a MFC View. You can add a class using wizard "Tangram Component" to create it. On the top of the right splitter pane is a C# component, you can use "Tangram Windows ControlLib" to create a C# project. And on the bottom of the right splitter pane is a VB document DLL. It is very easy to connect it to this program. Fill project name into the "Com Wnd" tab pane, and click "Create COM Window" button, then you will see the figure like above.

Sample Image - TangramDev.jpg

Interface each other by VBA engine

You can find VBA from option "Tools" in the menu bar. Each component can be mapped to a VBA Project Object (VBA Project Item and VBA Host Control). And each object in this application interfaces each other via the VBA engine.

Sample Image - TangramDev.jpg

How to create a control bar?

Find option "Tool" in the menu bar of this application, and open VBA interface, you will see the Designer Tool Window as the figure below. Fill the name you want in the textbox "Caption", of combobox "Create Docking Control Bar", then click button "Create ControlBar".

Sample Image - TangramDev.jpg

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here