Posted By


landock on 09/04/10

Tagged


Statistics


Viewed 463 times
Favorited by 0 user(s)

InDesign template changer


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. //template_switcher.jsx
  2. //An InDesign CS3 JavaScript
  3. /*
  4. @@@BUILDINFO@@@ "template_switcher.jsx" 1.0.0 14-September-2010
  5. */
  6. //Adds labels to the graphics in the active document.
  7. var myDocument = app.documents.item(0);
  8. main();
  9. function main(){
  10. if(app.documents.length != 0){
  11. if(app.documents.item(0).allGraphics.length != 0){
  12. swapGraphics();
  13. changeAddress();
  14. }
  15. else{
  16. alert("Document contains no graphics.");
  17. }
  18. }
  19. else{
  20. alert("Please open a document and try again.");
  21. }
  22. }
  23.  
  24. function swapGraphics(){
  25. var myGraphics = myDocument.allGraphics;
  26. for(var myCounter = myGraphics.length-1; myCounter >= 0; myCounter--){
  27. if(myGraphics[myCounter].itemLink.name == "30 Year Commerce CRG Logo.eps"){
  28. alert("see ya 30 year", "boom")
  29. myGraphics[myCounter].remove();
  30. }
  31. else
  32. if (myGraphics[myCounter].itemLink.name == "CCRG_CWLogo.eps"){
  33. alert("see ya old logo", "pow")
  34. myGraphics[myCounter].itemLink.relink ("\\\\delphi\\gigas\\2 - Logos\\CRESLogos\\EPS\\commerce__cw_standard.eps");
  35. myGraphics[myCounter].itemLink.update();
  36. }
  37. else
  38. if (myGraphics[myCounter].itemLink.name == "CCRG_CWLogo Reverse_BW_knockout.eps"){
  39. alert("see ya all white logo", "zing")
  40. myGraphics[myCounter].itemLink.relink ("\\\\delphi\\gigas\\2 - Logos\\CRESLogos\\CommerceLogos\\commerce_cw_white.ai");
  41. myGraphics[myCounter].itemLink.update();
  42. }
  43. }
  44. }
  45.  
  46. function changeAddress(){
  47. //Clear the find/change preferences.
  48. app.findTextPreferences = NothingEnum.nothing;
  49. app.changeTextPreferences = NothingEnum.nothing;
  50. //Set the find options.
  51. app.findChangeTextOptions.caseSensitive = false;
  52. app.findChangeTextOptions.includeFootnotes = false;
  53. app.findChangeTextOptions.includeHiddenLayers = false;
  54. app.findChangeTextOptions.includeLockedLayersForFind = false;
  55. app.findChangeTextOptions.includeLockedStoriesForFind = false;
  56. app.findChangeTextOptions.includeMasterPages = false;
  57. app.findChangeTextOptions.wholeWord = false;
  58. //Search the document for the string "copy" and change it to "text".
  59. app.findTextPreferences.findWhat = "commercecrg.com";
  60. app.changeTextPreferences.changeTo = "comre.com";
  61. app.documents.item(0).changeText();
  62. app.findTextPreferences.findWhat = "Commerce CRG";
  63. app.changeTextPreferences.changeTo = "Commerce Real Estate Solutions";
  64. app.documents.item(0).changeText();
  65. app.findTextPreferences.findWhat = "175 East 400 South, Suite 700 � Salt Lake City, Utah 84111";
  66. app.changeTextPreferences.changeTo = "170 South Main Street, Suite 1600 � Salt Lake City, Utah 84101";
  67. app.documents.item(0).changeText();
  68. app.findTextPreferences.findWhat = "175 East 400 South, Suite 700 | Salt Lake City, Utah 84111";
  69. app.changeTextPreferences.changeTo = "170 South Main Street, Suite 1600 | Salt Lake City, Utah 84101";
  70. app.documents.item(0).changeText();
  71. //Clear the find/change preferences after the search.
  72. app.findTextPreferences = NothingEnum.nothing;
  73. app.changeTextPreferences = NothingEnum.nothing;
  74. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.