Cant save excel file


$importcsv = join-path "$psscriptroot" "data.tsv"

$xl = new-object -com "excel.application"
$xl.visible = $true

$wb = $xl.workbooks.opentext($importcsv)

$wb.saveas("data.xlsx")

im getting error 

you cannot call method on null-valued expression.

excel opened should, not save it.

$wbpath=join-path $pwd 'data.xlsx' $importcsv=join-path $pwd 'data.tsv' $xl = new-object -comobject excel.application $xl.visible = $true $xl.workbooks.opentext($importcsv) $xl.displayalerts = $false $xl.activeworkbook.saveas($wbpath,51) $xl.quit() while([system.runtime.interopservices.marshal]::releasecomobject($xl)){'released'}  

you need this:


¯\_(ツ)_/¯



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Generating Event ID 91, 44 with CA (In Event Viewer with source as Certsvc)

Group policy default policy cannot be edited because network name not found

Problem when changing update source