How to close all windows after running the SaveAsPDF script?
I ran into the problem where I adjusted the SaveAsPDF script to backup my PDF files with a preset specific PDF I use. But after executing the script, all newly created PDF files are open in illustrator and I have to close it manually one by one, choose if I want to 'Save' or 'do not save' (even if they are already registered). I would like for them to close right after that the PDF is created.
I've added in the script:
if (myFile.open("w")) { myFile.close(SaveOptions.DONOTSAVECHANGES); }
Who's going to run the script and close the files, but for only 3 of the 10, I opened. The 7 remaining won't be saved or converted to PDF. Is there something wrong in my script or anything else that I can try to solve this problem?
Here is my complete script:
/** Saves every document open in Illustrator as a PDF file in a user specified folder. */ // Main Code [Execution of script begins here] try { // uncomment to suppress Illustrator warning dialogs //app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS; if (app.documents.length > 0 ) { // Get the folder to save the files into var destFolder = null; destFolder = Folder.selectDialog( 'Select folder for PDF files.', '~' ); if (destFolder != null) { var options, i, sourceDoc, targetFile; // Get the PDF options to be used options = this.getOptions(); // You can tune these by changing the code in the getOptions() function. for ( i = 0; i < app.documents.length; i++ ) { sourceDoc = app.documents[i]; // returns the document object // Get the file to save the document as pdf into targetFile = this.getTargetFile(sourceDoc.name, '.pdf', destFolder); // Save as pdf sourceDoc.saveAs( targetFile, options ); sourceDoc.close(); } alert( 'Documents saved as MarkPreset PDF' ); } } else{ throw new Error('There are no document open!'); } } catch(e) { alert( e.message, "Script Alert", true); } /** Returns the options to be used for the generated files. @return PDFSaveOptions object */ function getOptions() {var NamePreset = 'MarkPreset'; // Create the required options object var options = new PDFSaveOptions(); options.pDFPreset=NamePreset; // See PDFSaveOptions in the JavaScript Reference for available options // Set the options you want below: // For example, uncomment to set the compatibility of the generated pdf to Acrobat 7 (PDF 1.6) // options.compatibility = PDFCompatibility.ACROBAT7; // For example, uncomment to view the pdfs in Acrobat after conversion // options.viewAfterSaving = true; return options; } /** Returns the file to save or export the document into. @param docName the name of the document @param ext the extension the file extension to be applied @param destFolder the output folder @return File object */ function getTargetFile(docName, ext, destFolder) { var newName = ""; // if name has no dot (and hence no extension), // just append the extension if (docName.indexOf('.') < 0) { newName = docName + ext; } else { var dot = docName.lastIndexOf('.'); newName += docName.substring(0, dot); newName += ext; } // Create the file object to save to var myFile = new File( destFolder + '/' + newName ); // Preflight access rights if (myFile.open("w")) { myFile.close(SaveOptions.DONOTSAVECHANGES); } else { throw new Error('Access is denied'); } return myFile; }
Try this change
for (i = 0; i< app.documents.length;="" i++="" ) ="">
for (i = app.documents.length; i > 0; i--)
Tags: Illustrator
Similar Questions
-
How to close all active applications at the same time on the Acer Iconia A1 840
On my Android phone, I'm able to close all active applications at the same time the button next to the home button Task Manager. On my Acer Iconia A1 840 I don't have this option here. Is there another way to do it?
Thank you.
Lacoet,
To my knowledge unless you download a third party such as Advanced Task Killer App, you can only close applications active one at a time. If you are looking for an alternative, I suggest looking at game store of Google for a Task Killer app may be able to contribute to what you want to do.
-
How to record all windows updates in the external drive
Hello..
Please me tips on how to preserve all the updates of windows on an external drive.
I go for my laptop factory reset, before doing that, I want to ensure that I have all of my updates of windows over several years are retrieved to
an external drive. This way I can come back all my windows SP2, SP3 updates. Netframeworks and hundreds of ready updates.2. Please can you also tell me how to install these updates, I do not know if they are .exe or. MSI.
See you soon
Hello
I suggest you to follow the steps in this link and check if it helps:
http://support.Microsoft.com/kb/910339
It will be useful.
-
My internal hard drive went bad in my laptop, easy to replace and relatively inexpensive. However, the laptop came not with the windows disk. So, how can I reinstall windows once I replaced the hard drive?
Basically, you have two choices. You can communicate with the person who made the computer and see if they can provide either a set of Windows Vista restore disks (I would assume) or an installation for Windows Vista (probably OEM) DVD. If the second choice, determine if you will need to download device drivers or software packages from their web site. OR, you can purchase the operating system of your choice, retail. The wisdom is that, if this is your choice, you see if you will need the device drivers and get those of the web site of the manufacturer.
Once you have the disks, install in the usual way.
Tom Ferguson
-
How can I reinstall Windows after replacing the hard drive? I don't have the disk.
Windows Vista Edition Home Premium
My daughter has a computer with Windows Vista Home Premium. His hard drive went bad and I will install another. I would like to reinstall Windows Vista Home Premium, but can not find the disc. I don't have the license code information, but I can't find where I can download the program. Can someone help me?
Hello
Contact the computer manufacturer and ask them to send you to vista recovery disks to reinstall the operating system back as it was when you bought it
they do it for a nominal cost of $
or borrow a vista microsoft dvd; not a HP, Acer recovery disk etc
Make sure that you borrow the correct 32-bit or 64-bit microsoft dvd to your computer
they contain all versions of vista
This is the product key that determines which version of vista is installed
http://www.theeldergeek.com/Vista/vista_clean_installation.html
How to replace Microsoft software or hardware, order service packs and replace product manuals
-
Protection in real time in MSE stopped working after running the utility in Windows Live OneCare cleanup tool? Error Code: 0x800705b4
Hello Wally,
Thanks for posting your query on the Microsoft Community.
The question error codes and the description that you get suggests that you are facing problem when using MSE. This problem may occur if other security software, such as antivirus, antispyware and antimalware programs, are totally or partially installed on the computer.
I suggest to change firewall security settings or disable temporary security on the system software and try using MSE and see if it makes a difference. How to temporarily disable security software, you can view the article mentioned below.
Disable the antivirus
http://Windows.Microsoft.com/en-us/Windows7/disable-antivirus-software
Note: Antivirus software can help protect your computer against viruses and other security threats. In most cases, you should not disable your antivirus software. If you need to disable temporarily to install other software, you must reactivate as soon as you are finished. If you are connected to the Internet or a network, while your antivirus software is disabled, your computer is vulnerable to attack.
For more details, please see the article mentioned below and see that it helps you to fix the problem.
Real-time protection lights in Microsoft Security Essentials
Hope that the information provided is useful. Let us know if you have any concerns related to Windows. We will be more than happy to help you.
Kind regards
-
I received a book of 13-2000 HP Folio damaged software. Had to reload Microsoft Windows 7 Pro 64. Windows is not the updates even after running the Microsoft 'tool' and 'fix it tool. What is the last manual way to solve this problem.
What is the last manual way to solve this problem.
The last manual is to install the latest version of the Windows update client.
https://support.Microsoft.com/en-us/KB/3161647
Best regards, VZ
-
Hi all, I want to know what can I complie forms in windows and run the file met in the other operating system
3177349 wrote:
Hi all, I want to know what can I complie forms in windows and run the file met in the other operating system
It depends only on the BONE of the application server.
If your OS development and OS is different, you have to compile the fmb in the server again.
Hamid
-
How to close all the worksheets at once
Hello
How to close all the worksheets at the same time (with one click)?
It of so annoying to close one by one and asked if you want to save the script or not.
Thank you
Have you tried right-clicking on the name of the tab and selecting 'Close All '?
-
Impossible to uninstall Google Chrome. "Close all windows and try to uninstall.
Original title: try to uninstall google chrome it says first close all windows, but can not find open windows
trying to unstall google chrome it says close all Windows Google canfind first everything in the open wind
I faced this problem too, but I realized what the problem was.
Open the Task Manager and there you can find on Google Notifications running in the background.
Put an end (END TASK) and then try to uninstall chrome, it worked in my case.
NOTE: apart from this, you can find a few other tasks of chrome running in background.
Usually, they would have the Chrome icon, but sometimes, in the case of Notifications, the icon is different.
-
How to close a window of movie maker.exe
Remember - this is a public forum so never post private information such as numbers of mail or telephone!
Ideas: can someone help me to close a 'bad volume' opinion? "The wrong volume is in the drive. "does not even help remove the DVD.
- You have problems with programs
- Error messages
- Recent changes to your computer
- What you have already tried to solve the problem
How to close a window of movie maker.exe
====================================
The following steps may work for you:Launch the Task Manager / Ctrl + Shift + Esc / process tab
Complete the process on all instances of moviemk.exe
John Inzer - MS - MVP - Digital Media Experience - Notice_This is not tech support_I'm volunteer - Solutions that work for me may not work for you - * proceed at your own risk *.
-
How to close all programs to uninstall end
How to close all programs for the end of the uninstallation.
pls adviceHello
It is clear from the description that you want to close all programs to uninstall end
First of all the notes that you should not close all programs, because many of them are programs of the system and their closure will result in the failure of the system
- Right-click your taskbar and click on "Task Manager" or use the combination Ctrl + Alt Delete to open the Task Manager.
- In the processes window, select the programs you want to close, and then click "End task" at the bottom
If you want more help, reply to this message
Ashwin0
-
CS6 install on a Mac after running the beta version
I try to install the version of Photoshop CS6 on a Mac Pro after running the beta for the last months and can not install because of a few remaining pieces of the beta. How can I remove all the pieces and parts of the beat just the installer of version release?
This staring at me.
I found the uninstall script and was able to remove the old preferences.
-
How to close multiple windows of firefox (not mulitple tabs)
I often have several internet messaging Windows Open (often each window has several tabs). I would like to be able to leave all the windows with just a single closure of firefox. Currently, I can close each window with multiple tabs with a single large. I would like to extend this to several windows (each with several tabs).
I just right click on its icon in the Solution Explorer, and one of the options is to "close all windows", and that's all. I would like to see this option available in firefox. Thank youHi pyramidpower, you can go to the firefox menu and press the exit button to close all firefox windows open at the same time...
-
How will I know when to run the oracle table statistics?
I have a situation Here.Several weeks back, one of my application developer complained about the performance issue in one of the application. I looked at the table statistics, statistics on the table were outdated and ran the table statistics, query ran a lot faster. The same problem occurred in another application, and hoping that oracle will take the right decisions based on the statistics, I ran the statistics for the tables involved in the query, but this time things got worse? Why is this? According to oracle documentation the optimizer must have updated statistics on the tables and indexes that surround these tables, so how do we decide when to run the statistics on the tables by making sure that we have no worse things. Thank you
You don't tell us your version of db, but if you're on 10g and above, Oracle marks as out-of-date statistics when the RASSI percentage reaches or crosses the 10%. 11.1 from automatic work, managed by the ABP process runs nightly 10om at 02:00 on weekdays (can't recall for weekends) and supports the same. The question, when to collect the statistics is actually very subjective in your environment. Most of the time, it would be a weekly or a night and work in a data warehouse, in the next window ETL. You would need to play with the amount of the percentage of blocks of the table before you would be able to come to percentage that can work for your plans in a good way. I also saw the return of cardinality plays a large role in the exercise sometimes. You can watch here as well.
HTH
Aman...
Maybe you are looking for
-
I want to know if the ipad with this serial number DM * 5VJ if it still warranty
I want to know if the ipad with this serial number DM * 5VJ if it still warranty...
-
I use the digital indicator for my Countdown to 0 (zero). The thing is I don't like when the number of numbers to 0, and then view - 0. Someone knows how to set the display to 0 instead of - 0. Thank you
-
BBM iPhone how to recover deleted chat messages
How to retrieve deleted messages chat from my iPhone teens 6
-
Hello! I'm new to this forum & I need a little help. I recently made an insurance claim on my blackberry through my provider wirelesss & had everything set up on my old phone the same way for more than a year without changing. In any case, I forgot h
-
Es ist mir nicht possible, eine SmartShape-Form zu speichern. DAS kann zwar open werden DropDown-Menu equivalent. ES auch die selection (speichern/Aktualisieren form) green. Aber're is not possible [save form] durch Mausclick zu aktivieren.Version 8.