Bart Willems wrote:
> Ray wrote:
>> Hi,
>> I tried to call "xlApp.Columns.AutoFit=1" the whole program will crash,
>> but without xlApp.Columns.AutoFit=1, everything just fine.
>
> Autofit is a method. Also, columns are a method of a worksheet - try:
> xlApp.Worksheets.Columns("C:K").Autofit()
> (
Bart Willems wrote:
> Autofit is a method. Also, columns are a method of a worksheet - try:
> xlApp.Worksheets.Columns("C:K").Autofit()
Silly me. That is of course xlApp.Activesheet.Columns("C:K").Autofit()
On a sidenote, you can refer to a worksheet with xlApp.Worksheets(Name)
as well.
--
http
Ray wrote:
> Hi,
> I tried to call "xlApp.Columns.AutoFit=1" the whole program will crash,
> but without xlApp.Columns.AutoFit=1, everything just fine.
Autofit is a method. Also, columns are a method of a worksheet - try:
xlApp.Worksheets.Columns("C:K").Autofit()
(or whatever columns you need of c