Glowie
Glowie

Reputation: 2309

Powershell to create Excel with select highlighting

I am trying to create PowerShell that will highlight first 5 columns of the first row.

I tried this

$excel = New-Object -Com Excel.Application
$excel.Rows.Item("1:5").Interior.ColorIndex = 5

Among other variations in Item() and got strange output, i.e.

enter image description here

Thanks!

Upvotes: 1

Views: 46

Answers (1)

Donal
Donal

Reputation: 32723

This should do it:

$excel = new-object -comobject Excel.Application
$excel.visible = $true
$workbook = $excel.workbooks.add()
$sheet = $workbook.ActiveSheet
$sheet.Range("A1:F1").interior.colorindex = 5

Upvotes: 2

Related Questions