Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Property 'size' in Excel

Status
Not open for further replies.

Kazendar

Programmer
Oct 23, 2008
18
LB
I need solving for error at line 13, besides there are two warning/notes. The script is running but with these fails.

# xls_test.ps1

function Invoke() {
param([object]$m,
[string]$method,
$parameters)

$m.PSBase.GetType().InvokeMember($method, `
[Reflection.BindingFlags]::InvokeMethod, `
$null, $m, $parameters,$ciUS)
}

$ciUS = [System.Globalization.CultureInfo]'en-US'

$objExcel = New-object -comObject Excel.Application
$objExcel.visible = $True
$objWorkbook = Invoke $objExcel.Workbooks Add
$objWorksheet = $objWorkbook.worksheets | where {$_.name -eq "sheet1"}

$objWorksheet.cells.item(1,1).formulaLocal = "Value in cell A1"

[void]$objWorksheet.range("a1").addComment()
[void]$objWorksheet.range("a1").comment.visible = "$False ..."
## No text found in comment !

$range = $objWorksheet.activeCell.entireColumn
$range.autoFit
## nothing has changed !

$range = $objWorksheet.range("b1:b1")
$range.cells = "ColB Row1"
$range.font.size = 24
## Property 'size' cannot be found on this object;
## make sure it exists and is settable. `
## At C:\scripts\xls_test.ps1:32 char:13 + $range.font.s <<<< ize = 24

Invoke $objWorkbook SaveAs "c:\scripts\XLS_test.xls" > $null
Invoke $objWorkbook Close 0 > $null
$objExcel.quit()
 
What version of Excel are you using? When I run this against Excel 2007 the $range.autofit doesn't do anything (which I haven't investigated) but the $range.font.size does correctly change the size to 24 point.
 
Hi crobin1, i am using Excel 2007, and the error is still :

Property 'size' cannot be found on this object; make sure it exists and is settable. ............. etc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top