Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Change width of Excel Column

Reply
 
Old 07-23-2008   #1 (permalink)
The_Contrarian


 
 

Change width of Excel Column

Here's the script
-------------------
$a = New-Object -comobject Excel.Application
$a.Visible = $True
$b = $a.Workbooks.Add()
$c = $b.Worksheets.Item(1)
$c.Cells.Item(1,1) = "Service Name"
$c.Cells.Item(1,2) = "Service Status"


How can I set the width of the first column? I've been digging around the
excel object model and I'd think...

$c.Columns("1").ColumnWidth = 50

would work, but it doesn't.

My System SpecsSystem Spec
Old 07-23-2008   #2 (permalink)
Kiron


 
 

RE: Change width of Excel Column

Postimg it again, problem with my news reader I guess, sorry.
-------------------------------------------------------------
Subject: Re: Change width of Excel Column 7/23/2008 4:52 PM PST

By: Kiron In: microsoft.public.windows.powershell


Pretty close, just needed the .item and the [int] w/o quotes:

$c.columns.item(1).columnWidth = 50
# or...
$c.columns.item('a').columnWidth = 50

# other options...
$c.cells.item(1).columnWidth = 50
# or...
$c.range('a:a').columnwidth = 50

--
Kiron
My System SpecsSystem Spec
Old 07-24-2008   #3 (permalink)
The_Contrarian


 
 

RE: Change width of Excel Column



"Kiron" wrote:

Quote:

>
> Pretty close, just needed the .item and the [int] w/o quotes:
>
> $c.columns.item(1).columnWidth = 50
> # or...
> $c.columns.item('a').columnWidth = 50
Thank you. I tried permutations of quoting, but didn't think about the item
object.


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Solved Column width General Discussion
formatting output column width PowerShell
fixed width column import PowerShell
Excel 2007 Column and Width pixels not showing Vista General
Details View Column Width Defaults (Registry ??) Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46