Question batch file to clear contents in an excel file

ananthblaze

Prominent
Nov 8, 2018
4
0
510
Hi,

i need help in creating a batch file or a command prompt script to clear excel file contents without opening them

clear file contents of
file 1.xls
file 3.xls
file 4.xls

please help
 

kanewolf

Titan
Moderator
You can't clear them without "opening" them. You may not start Excel, but to access the contents of a file you have to open it.
Power shell can use the Excel DLL to provide access to Excel files.
Read up on things like this -- https://stackoverflow.com/questions...excel-workbook-from-powershell-for-automation

Although this sounds like a homework assignment, I will also say that you could copy a blank spreadsheet overtop of each of the files you want cleared.
 
  • Like
Reactions: Alabalcho

ananthblaze

Prominent
Nov 8, 2018
4
0
510
You can't clear them without "opening" them. You may not start Excel, but to access the contents of a file you have to open it.
Power shell can use the Excel DLL to provide access to Excel files.
Read up on things like this -- https://stackoverflow.com/questions...excel-workbook-from-powershell-for-automation

Although this sounds like a homework assignment, I will also say that you could copy a blank spreadsheet overtop of each of the files you want cleared.

Hi Kane,

thank you for replying...

this is a part of an improvement at work....im not good at coding
 
It depends a lot of what you call "clearing". I suppose that you want "clearing of some columns / rows, while preserving headings", something along these lines. This can be done with Excel Macros. You can even record some actions while doing them, and create a macro out of these.