Had a missing cell in that line, should read
Set xlapp = CreateObject("Excel.Application")
Set xlWb = xlapp.Workbooks.Add
Set xlWs = xlWb.Activesheet
With xlWs.Cells
.HorizontalAlignment = xlLeft
End With
and this works for me (but then again, so did your original). Have you set a
reference to
Again I ask, have you set a reference to Excel in the
VB project. If you
haven't, and you don't have Option Explicit at the start of the code, it
will run until it gets to that line then bomb out as there will be no value
associated with xlLeft (
VB does not have an xlLeft constant).
--
HTH
RP
(remove nothere from the email address if mailing direct)
"Phil" wrote in message
...
Hi,
Firstly, you need
Set xlapp = CreateObject("Excel.Application")
I do...
and have you set a reference to Excel in you VB6 project, openened a
wokbook, activated a sheet? I would use
dim xlapp as object
dim xlWb as object
dim xlWs as obejct
Set xlapp = CreateObject("Excel.Application")
Set xlWb = xlapp/Workbooks.Open(Filename:="c:\myBook.xls")
I am creating it on the fly, so I do not open one. I just create one and
fill in the sheets...All sheets are filled anyway...
Set xlWs = xlWb.Activesheet
With xlws
.HorizontalAlignment = xlLeft
End With
The message I get is: "This object doesn't handle this property of
method"...when getting to the .HorizontalAlignment line
Thanks