excel - Closing just CSVs -
how can close specific excel workbook in powershell?
i have script opens 4 csv files , xls file , manipulates data. having problem closing csv files , leaving xls file open.
i have tried $xl.workbooks.close()
closes everything. have tried $file.close()
still no luck. tried open workbooks this:
$xl3 = $xl.workbooks.open($wfile) | out-null $xl4 = $xl.workbooks.open($xfile) | out-null $xl5 = $xl.workbooks.open($yfile) | out-null $xl6 = $xl.workbooks.open($zfile) | out-null
and close them
$xl3.close()
you should able close csvs this:
$xl.workbooks | ? { $_.name -like '*.csv' } | % { $_.close($false) }
calling close
method savechanges
parameter set $false
discards unsaved changes file.
Comments
Post a Comment