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

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -