M
Michael Gao
Hi,
I wrote a PS script like this:
$a = New-Object -comobject Excel.Application
$a.visible = $true
$b = $a.Workbooks.Open("D:\out\M2.xlsx")
$i = 1
do {
$c = $b.worksheets.Item($i)
$c.name = $c.cells.item(2,2).value2
$i++
}while ($i -le $b.worksheets.count)
Some value may be the same, so I got error:
Exception setting "Name": "Cannot rename a sheet to the same name as another
sheet, a referenced object library or a workbook referenced by Visual
Basic."
At line 7, position 4
$c.name = $c.cells.item(2,2).value2
Does anybody met the same problem?
Thanks!
MG
I wrote a PS script like this:
$a = New-Object -comobject Excel.Application
$a.visible = $true
$b = $a.Workbooks.Open("D:\out\M2.xlsx")
$i = 1
do {
$c = $b.worksheets.Item($i)
$c.name = $c.cells.item(2,2).value2
$i++
}while ($i -le $b.worksheets.count)
Some value may be the same, so I got error:
Exception setting "Name": "Cannot rename a sheet to the same name as another
sheet, a referenced object library or a workbook referenced by Visual
Basic."
At line 7, position 4
$c.name = $c.cells.item(2,2).value2
Does anybody met the same problem?
Thanks!
MG