View Single Post
  #6   Report Post  
Posted to comp.lang.basic.visual.misc,microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default How to create Excel workbook from VB6?



"AustinMN" wrote in message
...
"Bob Phillips" wrote in message
...

"AustinMN" wrote in message
...
"Bob Phillips" wrote in message
...
Hi Kurt,

If you create an Excel instance, then you have access to all of the
objects.
so as an example

Dim xlApp As Object
Dim xlWB As Object
Dim xlWS As Object

Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True ' or not as required
Set xlWB = xlApp.Workbooks.Add
Set xlWS = xlWB.Worksheets.Add
'etc.


A better way (because it's early-bound):


It's horses for courses. Better in some instances, not so in others. It

is
not black and white.


The only problem is if the user has an earlier version of Excel and

you
use
a method or property that has been introduced since, your app will

crash
on
their machine.


And a later version may lose the reference (hence late bound)


While that's possible (Micro$oft can break anything), I've never

experienced
it. I've written over 100,000 lines of VBA specifically for Excel for 7
clients dating back to 1994. Not one line has broken because a method or
property has disappeared.


That's not what I said. I mentioned lost references. And if you think that
doesn't happen, just hang out here a while and you will see many examples.