Jump to content

excel: autosize column width?


gcue
 Share

Recommended Posts

hello.

im using the excel udf that comes with the new version of autoit 3.3.0.0

is there a way to autoexpand or autosize the column width?

i remember seeing the development of this udf and noting a _excelsetcolumnwidth function along the lines...

Link to comment
Share on other sites

In Excel, there's a method which can be applied to Range objects called AutoFit. I guess this is what you're after. In VBA:

ActiveSheet.Columns(1).AutoFit
Link to comment
Share on other sites

#include <Excel.au3>
Local $oExcel = _ExcelBookNew(1)
_ExcelWriteCell($oExcel, "Something Long Here", 1, 1)
_ExcelWriteCell($oExcel, "And something even longer", 2, 1)
$oExcel.ActiveSheet.Columns(1).AutoFit

Link to comment
Share on other sites

hmm not working... do i have to specify the activesheet name?

_ExcelSheetActivate($oExcel, "PRINTERS")
                    _ExcelWriteCell($oExcel, $asset_label, $p + 1, 1)
                    _ExcelWriteCell($oExcel, $asset, $p + 1, 2)
                    _ExcelWriteCell($oExcel, $printers[$p][0], $p + 1, 3)
                    _ExcelWriteCell($oExcel, "YES", $p + 1, 4)
                    _ExcelWriteCell($oExcel, $printernote, $p + 1, 5)
                    $oExcel.ActiveSheet.Columns(1).AutoFit

thanks for your help btw!!!

Edited by gcue
Link to comment
Share on other sites

You're using the first five columns. Try:

$oExcel.ActiveSheet.Columns("A:E").AutoFit
Link to comment
Share on other sites

  • 9 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...