March 26th, 2003, 2:40 pm
A good COM tutorial can be found at Developmentor/VBCOM Essentially though, every component you create in VB is COM (ActiveX) compliant. The link above will explain all this much more thoroughly though. Also, VB is essentially VBA (especially if you were using VBA in Office XP) with a few more libraries. You can check this in Project>References and see what components are automatically referenced by your project. Now back to the Automation problems.To early bind to Excel, you need to first reference the component, which I assume you are already doing, then declare a variable as shown below; ie do not use "as Object" or "as Variant". You can now either set this variable to a New instance of Excel, or use GetObject to reference an existing instance of Excel ie;Dim xl as Excel.ApplicationDim n as IntegerSet xl = New Excel.AppliocationFor n = 0 to 9999 xl.WorksheetFunction.Max 5, 4Nextxl.QuitSet xl = NothingA full explaination can be found at MSDN Automation ExplainationWith regards to execution speed, however, I would certainly write my own Math function library in an "in-process" component (read ActiveX Dll type project) You can always reuse this, and, if you install your app on someone elses machine that uses a different version of excel, you will not get any automation errors due to mismatched type libraries. Hope this helps