Save unsaved files

I need to save all open Excel, Word, and PowerPoint documents to a temp directory(C:\temp\), regardless if they have ever been saved or not.  The saved file will be the "CurrentDocumentTitle + Timestamp".Extension.  I can use WASP
to pull all open workbooks/documents in Excel, Word, and PowerPoint.  I can get A file to save, but it contains no content (at least unreadable).  I cannot seem to get this to work correctly, and I'm really hoping that this can be accomplished using
PowerShell.  The intent of this is to be able to run an Acrobat uninstaller across multiple systems in my domain using SCCM.  I'm asking the users to save their work and close their applications so the uninstaller can run, unfortunately, they are
not acting accordingly.  Any help would greatly be appreciated.
Set-ExecutionPolicy unrestricted -force
import-module C:\temp\WASP\WASP.dll -force #location of WASP
Function logstamp {
    $now=get-Date
    $yr = $now.Year.ToString()
    $mo = $now.Month.ToString()
    $dy = $now.Day.ToString()
    $hr = $now.Hour.ToString()
    $mi = $now.Minute.ToString()
    $se = $now.Second.ToString()
    if ($mo.length -lt 2) {
        $mo = "0" + $mo
    if ($dy.length -lt 2) {
        $dy = "0" + $dy
    if ($hr.length -lt 2) {
        $hr = "0" + $hr
    if ($mi.length -lt 2) {
        $mi = "0" + $mi
    if ($se.length -lt 2) {
        $se = "0" + $se
    write-output $yr$mo$dy$hr$mi$se
$logstamp = logstamp
$filepath = "C:\temp\"
$objects = Select-Window | Where-Object {$_.Title -like "*Excel" -or $_.Title -like "*Word" -or $_.Title -like "*PowerPoint"} #SEARCHES FOR ALL OPEN WINDOWS OF LISTED TYPES (SAVED OR UNSAVED)
foreach($file in $objects){
    If ($file.Title -like "*Excel"){ #Set extension for Excel
        $ext = ".xlsx"
        #$a = New-Object -comobject Excel.Application
        #$a.Visible = $true
        #$book = $a.Workbooks.open($file)
        #$book.Save($filepath + $file.Title + $logstamp + $ext)
        #$a.Quit()
    Elseif ($file.Title -like "*Word"){ #Set extension for Word
        $ext = ".docx"
    Elseif ($file.Title -like "*PowerPoint"){ #Set extension for PowerPoint
        $ext = ".pptx"
    $ofile = out-file ($filepath + $file.Title + $logstamp + $ext)
$ofile

When I ran it on my system with the where $_.processname it showed every open workbook:
ProcessName : EXCEL
ProcessId : 4440
IsActive : False
Handle : 66246
Title : Microsoft Excel - 192.168.82-SubnetInfo.csv
Class : XLMAIN
ProcessName : EXCEL
ProcessId : 4440
IsActive : False
Handle : 1116514
Title : 192.168.82-SubnetInfo.csv
Class : MS-SDIb
ProcessName : EXCEL
ProcessId : 4440
IsActive : False
Handle : 334352
Title : DHCP for JnJ IP Ranges - NA.xlsx
Class : MS-SDIb
ProcessName : EXCEL
ProcessId : 4440
IsActive : False
Handle : 1120668
Title : 1Synthes_IP_Renumbering_tracker_9 15.xls [Protected View] [Compatibility Mode]
Class : MS-SDIb
ProcessName : EXCEL
ProcessId : 4440
IsActive : False
Handle : 462498
Title : Synthes US - New VLAN.xlsx
Class : MS-SDIb
In your section of code for Excel and for the other files, unless the file is in the same path as the script you'll never touch it.  And even then you'll only be touching the version before the user has made any edits.  The only way you can take
action on the existing, open, edited, unsaved version of the file that I'm aware of is to use the 
[Runtime.Interopservices.Marshal]::GetActiveObject
Method.
I hope this post has helped!

Similar Messages

  • How can tell the script I want to save unsaved files but not replace the old one?

    Hi everyone
    I got this script
    var docs = app.documents; 
    for (var i = docs.length-1; i >= 0; i--) { 
        if (docs[i].saved == false) { 
            docs[i].save(new File(“~/Desktop/Document.indd”)); 
            docs[i].close(); 
        else { 
            docs[i].close(SaveOptions.YES); 
    close and save files
    but if I have two or more files, I want to save files like Doc1, Doc2...
    the new file will never replace the old one
    Can some one tell me how can I do that?
    Thanks
    Regard
    Teetan

    Hi,
    Change the 4th line like below:
            docs[i].save(new File("~/Desktop/Doc" + (i+1) + ".indd"));
    Vandy

  • How to save unsaved changes to pdf file?

    Hi,
    I have a plugin for signature creation and verification created using acrobat sdk 9 and testing in acrobat x. When user initiates a signature creation process, in SigGetSigProperties() callback, i need to save any unsaved changes in the pdf file before i proceed with the signature creation process. To achieve this i added this code to SigGetSigProperties() callback:
    // Save unsaved changes to file.
    AVDoc avDoc = AVAppGetActiveDoc();
    if( avDoc )
    PDDoc pdDoc = AVDocGetPDDoc(avDoc);
    // save unsaved changes
    PDDocSave(pdDoc, PDSaveIncremental, NULL, NULL, NULL/*AVAppGetDocProgressMonitor(NULL)*/, NULL);
    But this code generates this error:
    Creation of this signature could not be completed.
    Unknown error
    supported information: CDSHandler-657
    and
    Creation of this signature could not be completed.
    Error at File: ..\sources\DSHandler.cpp , Line: __LINE__
    What am i doing wrong here? is this the right approach and is there a better way to achieve this?
    thanks and regards,

    Hi,
    Actually, i need to save the pdf just before signing starts. saving at idle handler will not fullfil our requirements. how can i achieve this?
    And keeping in mind the above requirement, when i think about adding a button or menu item, as u suggested, the only thing that comes in my mind is that, i disable the signature creation button and add my own button for signature. When its presses i save the pdf and internally call the acrobat's default signature button to start the signing process. But firstly i dont know if its possible. and secondly, there still remains the scenario where the user clicks an empty field to start the signing process.
    what should i do?

  • Animated gif's from unsaved file?

    I used to be able to create animated gif's easily from unsaved files. I would simply select all the layers I wanted to use and process them.
    After upgrading to CS6, I'm totally lost. I've followed half a dozen tutorials, but nothing works. The only way I can even load a frame into the Windows Timeline feature is to first save several images from my unsaved file, then reload them by choosing File > Scripts > Load Files into Stacks. But even then I can't find a Make Frames from Layers option when I click the down arrow on the right side of the palette.
    Is there a simple way to create animated gif's from layers in an unsaved file on CS6, or do I need to reinstall my older Photoshop version in order to created animations?
    Thanks.

    Yes, I clicked Frame Animation Mode, but that's as far as I can get. It doesn't work the same as my older version of Photoshop. The only buttons that appear to function on the left side of the palette are "Split at playhead" and "Select a transition," and they actually don't do anything.
    The tutorials tell me to click the down arrow on the right side of the palette and choose "Make Frames from Layers," but that choice isn't listed. The choices that are listed include "Loop Playback" and "Allow Frame Skipping."
    I've tried several tutorials and have experimented with just about every button and arrow I can find, but I can't get any farther than the image you posted.

  • Recover a unsaved file in Pages '09 v4.2

    Hi All,
    I hope someone can help me to recover a couple of unsaved files. I was working on Pages '09 with several Pages opened and in an accidental click I closed two of these with out save. Do you know how to recover files from a Temp Folder or any Similar?
    Thanks in advance,
    -Daniel.

    Since you're using Lion & Pages 4.2 autosave will have saved the files if you have saved them at least once. There is a folder of "unsaved documents" in HD > Users > (your account) > Library > Preferences but I have no idea how it works. The one time I tried opening one of the files I got an error, but you might have a different result. In Lion you need to go to Finder, hold down the Option key while clicking on the Go menu & your users Library will appear about halfway down the list.

  • AI CS3 Plugin: When I close the Illustrator application, it's not saving the unsaved file.

    Hi Everybody,
    Version: AI CS3
    OS: Windows XP
    I've an AI plug-in which defines its own file format, with .ai extension itself. In the VC++ code of the plugin, I spawn .jsx file to do the validation (if it's out of the artboard, illegal font and so on). Using the plug-in, every other functionality is working fine except for one thing, i.e., while closing the application. When I try to close the application, it gives a prompt asking if you want to save the unsaved .ai file( Yes, No and Cancel Prompt). If I click on Yes, it should actually save the file and then exit. Here, since validation is done using a different file (.jsx file), it calls that file only after exiting the vc++ code. While closing the application, the file is getting called in vc++ code, but it happens only after exiting vc++ code, so there is no process to handle that file since I'm closing the Illustrator itself. It exits by throwing an exception- unable to read the particular location. Would anyone please tell me how to deal with this?

    Hi Sharon
    Hmmm, where exactly *IS* the focus in your tests after
    closing the RoboHelp generated .CHM file? I just tested and saw the
    same behavior regardless of whether it was a Microsoft .CHM or a
    RoboHelp HTML created .CHM. Each time, the focus was returned to
    Windows Explorer.
    I do know that the manner in which your developers open a
    .CHM can vary. For example, your developer can specify that a
    particular tab have focus, such as the Index or TOC, while simply
    double-clicking will result in the last opened tab being the active
    tab.
    Wish I had more to offer here, but I'm not seeing the same
    behavior as you are. I do know there are some extended settings for
    your window, but I'm doubtful that's the answer here.
    Also, I'm not too sure how much stock I'd put in something a
    Microsoft call center stated. Just the nature of call centers. Some
    folks that staff them are good and skilled, some are a bit, shall
    we say, lacking. This is truly "Luck of the draw".
    Sincerely... Rick

  • Adobe photoshop cc 2014 won't close window with unsaved file

    Recently installed update to Photoshop via creative cloud. Photoshop works great but for some reason I am unable to close a window with an unsaved project. Pressing command-w or going to file close doesn't do anything. As soon as I save the file I can close the window or quit photoshop. Is this in the preferences? Please advice.
    thanks

    I'm having this same issue.  Can't close an unsaved file that has been opened, even if it is completely unedited.  When an unsaved file is present, I can't quit Photoshop, either.
    I'm on OSX 10.7.5  (yes, I know...it's aged), Photoshop CC.  Plenty of memory and disk space, so that's not the issue.
    Any ideas?  Thanks!

  • Script to create directory based on current file name and then save the file in that directory

    Hi all,
    I have a need save all my projects in a directory using the name of the main image I am working on.
    Manually these are the steps I used:
    Save As.
    Copy ( press command-c <== the filename is highlighted by default so all I have to do is )
    New Folder ( press the new folder button. Brings up a dialog box)
    Paste ( press command-v. <== Pastes the file name into the "New Folder" dialog box.)
    Save ( press thre save button. Saves the files into the new folder )
    Save As.
    Change format to JPG
    Save
    Change image quality to 12
    I want to assign these actions to a key
    Recording these steps and playing them back does not give me the results I need, snce the original name is hard-coded in the actionlist that was recorded
    What should I be doing instead ?
    Thanks in advance !

    You don’t mention which format the original file is (and figuring that and its current settings out seems too much of a hassle to me) so this would only save the jpgs into the folder (and create one if it does not exist).
    If you want to give it a try, paste the following text into a new file in ExtendScript Toolkit (part of Photoshop’s installation, Applications/Utilities/Adobe Utilities/ExtendScript Toolkit CS4 or /Applications/Utilities/Adobe Utilities-CS5/ExtendScript Toolkit CS5) and save it as a jsx-file into Photoshop’s Presets/Scripts-folder.
    After restarting Photoshop the Script should be available under File > Scripts and can be assigned a Keyboard Shortcut directly, recorded into an Action, (in CS4 and CS5) be used in a Configurator-Panel or started from ExtendScript Toolkit directly.
    // saves jpg into folder of file’s name next to file;
    // be advised: this  overwrites existing jpgs of the same name without prompting;
    // thanks to xbytor;
    // 2012, use it at your own risk;
    #target photoshop;
    if (app.documents.length > 0) {
    var thedoc = app.activeDocument;
    // getting the name and location;
    var docName = thedoc.name;
    if (docName.indexOf(".") != -1) {var basename = docName.match(/(.*)\.[^\.]+$/)[1]}
    else {var basename = docName};
    // getting the location, if unsaved save to desktop;
    try {var docPath = thedoc.path}
    catch (e) {var docPath = "~/Desktop"};
    // create folder if it does not exist;
    var folderString = docPath+"/"+basename;
    if (Folder(folderString).exists == false) {new Folder(folderString).create()};
    // jpg options;
    var jpegOptions = new JPEGSaveOptions();
    jpegOptions.quality = 12;
    jpegOptions.embedColorProfile = true;
    jpegOptions.matte = MatteType.NONE;
    //save jpg as a copy:
    thedoc.saveAs((new File(folderString+"/"+basename+".jpg")),jpegOptions,true);

  • My mac froze and shut down. Is there a way to retrieve unsaved files?, My mac froze and shut down. Is there a way to retrieve unsaved files?

    My mac froze then shut down. Is there a way to retrieve my unsaved files?

    It depends what you are using, you haven't told us, and whether you ever saved in the first place which you also haven't told us.
    In OSX Lion (OSX 10.7) Pages will have auto-saved after the initial save and reopening the file will take you back to the last save.
    Prior to Lion you would only have the last saved version. Utilities like ForEverSave would have auto-saved for you or you would need to manually save with command s.
    If your whole Mac froze and it wasn't a battery issue in a laptop, then I would try and determine the reason as this should not be happening.
    Peter

  • Unable to save edited files

    Hello Group,
    Has anyone experienced this problem?? We have had this
    problem 2 times, and it seems related to after a Windows automatic
    update as run. Platform is an HP laptop, running windows XP.
    We have several *.cp files. We open one file, and delete an
    audio track from a slide, and then attempt to save the edited file.
    The edited file will not save. For some reason Captivate
    still sees the "different" file name as the same name as previous
    file. The edit is not saved. We even created a new folder on the
    C:\ drive, and copy a file in, open it, or attempt to open an
    edited file that somehow got saved, and then Captivate say "this
    file is in a format that captivate does not recogize"
    Has anyone else seen something like this?
    captivate seems to work ok on my desktop pc, but not the
    laptop??? Perhaps it is some sort of problem with the laptop
    Thanks,
    eholz1

    I was wondering if either of you have had any luck nailing
    down this problem. We are experiencing it on one of our laptops as
    well and I have been baffled by it.
    The laptop is a Dell with XP SP2, it was running Captivate
    1.0.1 for a while and was upgrade to Captivate 2.0 without removing
    Captivate 1. This configuration has worked for months, but suddenly
    I can't save anything. If you hit save the hourglass pops up and
    goes away with no error messages, but the * in the titlebar
    indicating unsaved changes is still there and when I try to close
    it asks to save. If I say no or cancel it acts properly, but if I
    hit yes to save it, is just goes back to Captivate and doesn't
    close or save. Save As will save a file, but it is usually corrupt
    when I try to open it later, and the * still doesn't go away.
    I have gone so far as to run ProcessMonitor from Sysinternals
    but it doesn't show any errors. It doesn't even show that it is
    trying to save it. If there are any patches or updates for
    Captivate 2 I have been unable to find them on Adobe's site.

  • Inability to save edited files

    I can no longer save edited text in Adobe Acrobat X1.
    I now have error "This document could not be saved. There was a problem reading this document (109)"
    Any help is appreciated.
    Abonzo

    I was wondering if either of you have had any luck nailing
    down this problem. We are experiencing it on one of our laptops as
    well and I have been baffled by it.
    The laptop is a Dell with XP SP2, it was running Captivate
    1.0.1 for a while and was upgrade to Captivate 2.0 without removing
    Captivate 1. This configuration has worked for months, but suddenly
    I can't save anything. If you hit save the hourglass pops up and
    goes away with no error messages, but the * in the titlebar
    indicating unsaved changes is still there and when I try to close
    it asks to save. If I say no or cancel it acts properly, but if I
    hit yes to save it, is just goes back to Captivate and doesn't
    close or save. Save As will save a file, but it is usually corrupt
    when I try to open it later, and the * still doesn't go away.
    I have gone so far as to run ProcessMonitor from Sysinternals
    but it doesn't show any errors. It doesn't even show that it is
    trying to save it. If there are any patches or updates for
    Captivate 2 I have been unable to find them on Adobe's site.

  • TextEdit.app won't save new files to sub-firs of my Documents dir

    This just started happening recently. Right after I installed the last Pages update AAMOF.
    I can successfully save a new document (.rtf) file to my Documents, but not to any sub-dir. The error dialog box says it can't save because file doesn't exists. And, this gets logged to the console:
    TextEdit[283]: view service marshal for <NSRemoteView: 0x7fe8cb422cd0> failed to forget accessibility connection due to Error Domain=NSCocoaErrorDomain Code=4099 "Couldn’t communicate with a helper application."
    It's just TextEdit that's doing this, no other apps seem too be affected.

    Thanks Griff W,
    I ran disk utility, and although it reported lots of permissions issues with the iBooks app and some Printer stuff, nothing related to TextEdit.
    I've done a little more investigating...
    This is only happening on my i7 iMac at work. Everything is fine on my MacBook Pro and my i5 iMac at home. So, I guess we can discount the Pages update having anything to do with this.
    Everything is up to date, updates wise, on all of my machines listed above.
    I did enable FileVault encryption on my work i7 iMac around the 1st week of August. That could have possibly messed something up with TextEdit??
    Again, this is just happening with TextEdit, when trying to save a new document to a sub-directory of my Documents dir. Similar saves to other directories and/or sub-dirs work just fine.
    If I save a new TextEdit document to my Documents dir, that works. And, if I then move it to a sub-dir, I can successfully edit and save it again with TextEdit.
    This is the message I get in the TextEdit dialog box when doing a failed new document save: The document “Untitled” could not be saved as “See.rtf”. The file doesn’t exist.What the heck does that mean anyway? The document/file "Untitled" doesn't exist.. well of course not, it's a new document!
    I do have a bad habit of keeping unsaved "notes, reminders, todos, etc." as TextEdit documents laying around. And, doing logouts, reboots, etc. with these "unsaved" documents still laying around. Could that have contributed to this issue?
    This isn't exactly a show stopper, I can work around it. It's more annoying then anything. Any ideas on how to fix things will be appreciated though.
    -Rob

  • HT201250 I accidentally didn't save a document on my desktop--a report.  Can I go back with time machine and recover my desktop and save the file?

    I accidentally didn't save a document on my desktop--a report.  Can I go back with time machine and recover my desktop and save the file?

    If you saved it at least once, then time machine should have a copy of the document at the state you last saved it.  I'm guessing tha's not the case however or the copy of the file would still be on your Desktop.
    If you never saved it a single time, yet closed the window and dismissed the warnings about an unsaved document, then you are out of luck as far as I know.

  • I have an external hard drive, from Iomega. However, I cannot copy or save any file to it. On my PC it says that is possible to read and write in it, but in my Mac, it says I can only read. can somebody help me?

    I have an external hard drive, from Iomega. that I can open and see my files. However, I cannot copy or save any file to it. On my PC I have it says that is possible to read and write in it, but in my Mac, it says I can only read. can somebody help me?
    Also, Im a photographer, so I like to name a lot of files at the same time (used to do in on PC and it was very usefull.) cannot find out how to do it on my Mac. Really appretiate if some one can give me a solution! Thanx

    Your drive is formatted with the NTFS file system.  OS X can read but not write to the NTFS file system.  There are third party drivers available that claim to add the ability to OS X to write to an NTFS partition.  I have not tried them and don't know if they work.
    The only file system that OS X and Windows can both write to natively is the FAT32 file system.

  • Why do I get a program error when trying to save a file

    I've loaded and reinstalled photoshop elements 3 times. I can not save any files. all i get is cannot save file do to  program error message'
    this is a brand new product with a program error and they want me to pay them to fix there problem. it ain't right.

    which version of Photoshop Elements are you using? Also, do tell us about the flavour of Operating System you are using and the format in which  you are trying to save your file.
    You can also try saving your file to a different location( e.g. desktop) to check if your computer has any permission issues

Maybe you are looking for

  • Club newsletter in MS Word arrives blank

    I had been receiving our local Rotary Club newsletter, which the editor composes in a Windows version of MS Word, just fine until recently. Now when I download the document (which appears on the desktop as the standard Word icon), it opens to a blank

  • For loop in a recursion

    I am trying to write a program in which a series of numbers are generated by a recursive function based on strict number rules... such as the first number is always 94 and it can be only followed by 94,95,96,97, etc... I would like to get some help b

  • Problems with L8

    Hi All, I have L8 autoloader with 8 tape media- 8th is a cleaning tape. In the first try I have set up jukebox and was able to backup the server where I have Sun Storedge Enterprise BackUp Software 7.2 is installed and another XP client. But I notice

  • WS-addressing through Oracle Service Bus

    Hi, I'm trying to setup a business process, which is running on IBM WebSphere Process Server, and this need to call a web service through Orcale Service Bus, asynchronously (since this is a long running web service, the process will call it and wait

  • Tuxedo and MS DTC

    Has someone already used Tuxedo with MS DTC? thanks, Andre S. David