Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

excel: autosize column width?


  • Please log in to reply
7 replies to this topic

#1 gcue

gcue

    just a wannabe

  • Active Members
  • PipPipPipPipPipPip
  • 1,872 posts

Posted 14 April 2009 - 02:03 PM

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...







#2 WideBoyDixon

WideBoyDixon

    Code Monkey

  • Active Members
  • PipPipPipPipPipPip
  • 381 posts

Posted 14 April 2009 - 02:16 PM

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


#3 gcue

gcue

    just a wannabe

  • Active Members
  • PipPipPipPipPipPip
  • 1,872 posts

Posted 14 April 2009 - 02:18 PM

so how can i use that syntax in autoit?

#4 WideBoyDixon

WideBoyDixon

    Code Monkey

  • Active Members
  • PipPipPipPipPipPip
  • 381 posts

Posted 14 April 2009 - 02:27 PM

#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


#5 gcue

gcue

    just a wannabe

  • Active Members
  • PipPipPipPipPipPip
  • 1,872 posts

Posted 14 April 2009 - 02:41 PM

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, 14 April 2009 - 02:41 PM.


#6 gcue

gcue

    just a wannabe

  • Active Members
  • PipPipPipPipPipPip
  • 1,872 posts

Posted 14 April 2009 - 02:44 PM

ahh nevermind!! i got it... columns(##)

hehe

thanks again!

#7 WideBoyDixon

WideBoyDixon

    Code Monkey

  • Active Members
  • PipPipPipPipPipPip
  • 381 posts

Posted 14 April 2009 - 02:48 PM

You're using the first five columns. Try:
$oExcel.ActiveSheet.Columns("A:E").AutoFit


#8 gcue

gcue

    just a wannabe

  • Active Members
  • PipPipPipPipPipPip
  • 1,872 posts

Posted 14 April 2009 - 02:54 PM

even better... many many thanks!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users