Saturday, April 3, 2010

How To Excel VBScript Autofit

How To Excel VBScript Autofit

Dim excel,wb,ws
set excel=WScriptCreateObject("Excel.Application");
'... get a workbook by add or open
'... get a worksheet from the workbook using the Sheets() collection
'... set ws to that worksheet

' To fit the first 10 columns
for column=1 to 10
ws.columns(column).AutoFit()
next

' To fit the third row
ws.rows(3).AutoFit()

[Via]