delete worksheet from .xlsm file
I am trying to delete a named Worksheet from an .xlsm file. I followed the example posted here but it is not working for me. When I open the .xlsm file to check whether the Worksheet has been deleted, it is still there. Here is my code: $file2 = 'c:\file.xlsm' # destination's fullpath $xl = new-object -c excel.application $xl.displayAlerts = $false # don't prompt the user $wb2 = $xl.workbooks.open($file2) # open target $sh2_wb2 = $wb2.sheets | where {$_.name -eq "myWorksheet"} $sh2_wb2.delete() #Delete original sheet in template $wb2.close($true) # close and save destination workbook $xl.quit(
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.