Share on FacebookThis is a primer on using OLE Automation to create an Excel instance in Visual Basic 6.0 and control Excel from a VB6 Application. The following would also apply for Automating Excel from another Office Application such as Word, Access or Outlook.
The first step in Automating Excel is to add a Reference to the Microsoft Excel Object Library:
(1) Within VB 6.0, choose Alt|Project|References...
(2) Scroll down until you find "Microsoft Excel 10.0 Object Library", which could also be 8.0, 9.0, 11.0, or 12.0, depending on which version of Excel you are using. Click within the check box and then click <OK>. Now your Library reference is loaded.
Next you write your code! Bellow you will find a tested example...
