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

WIMMount (HSM) causing cluster storage to go redirected (2012r2 DC)

Failed to delete the test record dcdiag-test-record in zone test.com

Azure MFA with Azure AD and RDS