Batch file to save the unsaved opened documents

Hi,

I am running an batch file through scheduled task that shut down my pc at specified time interval, i want an batch file that saves the unsaved open documents just prior to the shutdown activity.
srikanth2322Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

btdownloads7Commented:
That isn't possible. There is no program that can detect which files haven't been saved, nor is there a program that can tell other programs (like Word, Excel, Photoshop, or potentially a million others) to save their open files.
srikanth2322Author Commented:
if it can't recognise the unsaved documents, can the batch file save all the open documents to the specified path.
btdownloads7Commented:
No, because no batch file can know what "unsaved documents" are. In fact, no batch file can know what documents are open at all. At best, you can get a batch file to see what programs are open, but there is no way to tell those programs to save their open files, let alone tell the programs where to save them.
Acronis True Image 2019 just released!

Create a reliable backup. Make sure you always have dependable copies of your data so you can restore your entire system or individual files.

srikanth2322Author Commented:
can we autosave all the documents opened through office products like word,excel,ppt.
instead of saving it manually.
btdownloads7Commented:
You should be able to do that usnig VBScript. Here's a script to do it, however, this script will only save existing open files. If you are working a new file, and have never saved it before, this won't work because those files have to be "saved as".
Dim objWord, objExcel, objPPT

Set objWord = CreateObject("Word.Application")
For Each doc In objWord.Documents
   doc.save
Next

Set objPPT = CreateObject("Powerpoint.Application")
For Each ppt In objPPT.Presentations
   ppt.save
Next

Set objExcel = CreateObject("Excel.Application")
For Each wbook In objExcel.Workbooks
   wbook.save
Next

Open in new window

btdownloads7Commented:
I just realize that I have a typo in the script above -- the .Save method should be capitalized. Here's the revized script:
      Dim objWord, objExcel, objPPT

Set objWord = CreateObject("Word.Application")
For Each doc In objWord.Documents
   doc.Save
Next

Set objPPT = CreateObject("Powerpoint.Application")
For Each ppt In objPPT.Presentations
   ppt.Save
Next

Set objExcel = CreateObject("Excel.Application")
For Each wbook In objExcel.Workbooks
   wbook.Save
Next

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
srikanth2322Author Commented:
excellent
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Applications

From novice to tech pro — start learning today.