Ole excel objects in VB6

Does anyone know of a good online resource for detailed information on using ole excel objects (embedded workbooks, worksheets, etc.) in VB6? I maintain an application that makes heavy use of these controls, and I have a lot of problems getting them to work correctly for the user of this program. The scattered Q&A bits I can find on the internet related to ole excel controls are very limited and not very definitive. Obviously I've read what is on MSDN, but I don't find it very useful, so I would like to find another good source of references.

thank

+1


source to share


2 answers


I'm not sure if this is useful for embedding Excel, but assuming the Excel engine is at the heart of the embedded controls, you can look here for an alphabetical reference of the objects available for Excel 2003.

And here's for the root of the Excel VBA reference, which includes a Concepts section that discusses basic objects like workbooks and worksheets, cells and ranges, etc.

You will need to link to Excel objects in your project before you can create any of these objects. In the Project / References section, you will find something like "Microsoft Excel 9.0 Object Library". (I have Office 2000, and therefore 9.0. Based on the links above, I am assuming that for Excel 2003, you will see Excel 11.)

In your code, do something like this:



' Start a new workbook in Excel '

Dim oExcel As Excel.Application
Dim oBook As Excel.Workbook

' Launch an instance of Microsoft Excel '
Set oExcel = new Excel.Application
Set oBook = oExcel.Workbooks.Add

      

Then move on to code against app, books, etc. The above code will create an instance of Excel that is not embedded, but its own window. One thing to be aware of is that by default this instance of Excel will not be visible. Before you can see it, you must set the Visible property to True.

Hope it helps.

+2


source


Any Excel VBA workbook should help as you can copy and paste code from VBA to VB6. I would start there.



Also trying to do what you want to do in Excel with VBA then including it in a VB6 project will help as well. Then you will have access to all the VBA help in Excel (if you have it installed .. it is not always installed by default).

+1


source







All Articles