Return to Snippet

Revision: 31413
at June 11, 2011 07:10 by landock


Updated Code
//template_switcher.jsx
//An InDesign CS3 JavaScript
/*  
@@@BUILDINFO@@@ "template_switcher.jsx" 1.0.0 14-September-2010
*/
//Adds labels to the graphics in the active document.
var myDocument = app.documents.item(0);
main();
function main(){
	if(app.documents.length != 0){
		if(app.documents.item(0).allGraphics.length != 0){
			swapGraphics();
			changeAddress();
		}
		else{
			alert("Document contains no graphics.");
		}
	}
		else{
		alert("Please open a document and try again.");
	}
}

function swapGraphics(){	
	var myGraphics = myDocument.allGraphics;
	for(var myCounter = myGraphics.length-1; myCounter >= 0; myCounter--){
		if(myGraphics[myCounter].itemLink.name == "30 Year Commerce CRG Logo.eps"){
				alert("see ya 30 year", "boom")
				myGraphics[myCounter].remove();
		}
		else 
			if (myGraphics[myCounter].itemLink.name == "CCRG_CWLogo.eps"){
				alert("see ya old logo", "pow")
				myGraphics[myCounter].itemLink.relink ("\\\\delphi\\gigas\\2 - Logos\\CRESLogos\\EPS\\commerce__cw_standard.eps");
				myGraphics[myCounter].itemLink.update();
			}
		else 
			if (myGraphics[myCounter].itemLink.name == "CCRG_CWLogo Reverse_BW_knockout.eps"){
			alert("see ya all white logo", "zing")
			myGraphics[myCounter].itemLink.relink ("\\\\delphi\\gigas\\2 - Logos\\CRESLogos\\CommerceLogos\\commerce_cw_white.ai");
			myGraphics[myCounter].itemLink.update();			
			}
	}
}

function changeAddress(){
	//Clear the find/change preferences.
	app.findTextPreferences = NothingEnum.nothing;
	app.changeTextPreferences = NothingEnum.nothing;
	//Set the find options.
	app.findChangeTextOptions.caseSensitive = false;
	app.findChangeTextOptions.includeFootnotes = false;
	app.findChangeTextOptions.includeHiddenLayers = false;
	app.findChangeTextOptions.includeLockedLayersForFind = false;
	app.findChangeTextOptions.includeLockedStoriesForFind = false;
	app.findChangeTextOptions.includeMasterPages = false;
	app.findChangeTextOptions.wholeWord = false;
	//Search the document for the string "copy" and change it to "text".
	app.findTextPreferences.findWhat = "commercecrg.com";
	app.changeTextPreferences.changeTo = "comre.com";
	app.documents.item(0).changeText();
	app.findTextPreferences.findWhat = "Commerce CRG";
	app.changeTextPreferences.changeTo = "Commerce Real Estate Solutions";
	app.documents.item(0).changeText();
	app.findTextPreferences.findWhat = "175 East 400 South, Suite 700 � Salt Lake City, Utah 84111";
	app.changeTextPreferences.changeTo = "170 South Main Street, Suite 1600 � Salt Lake City, Utah 84101";
	app.documents.item(0).changeText();
	app.findTextPreferences.findWhat = "175 East 400 South, Suite 700 | Salt Lake City, Utah 84111";
	app.changeTextPreferences.changeTo = "170 South Main Street, Suite 1600 | Salt Lake City, Utah 84101";
	app.documents.item(0).changeText();
	//Clear the find/change preferences after the search.
	app.findTextPreferences = NothingEnum.nothing;
	app.changeTextPreferences = NothingEnum.nothing;
}

Revision: 31412
at June 11, 2011 07:02 by landock


Updated Code
//myshit.jsx
//An InDesign CS3 JavaScript
/*  
@@@BUILDINFO@@@ "myshit.jsx" 1.0.0 14-September-2006
*/
//Adds labels to the graphics in the active document.
var myDocument = app.documents.item(0);

main();

function main(){
	if(app.documents.length != 0){
		if(app.documents.item(0).allGraphics.length != 0){
			swapGraphics();
			changeAddress();
		}
		else{
			alert("Document contains no graphics.");
		}
	}
	else{
		alert("Please open a document and try again.");
	}
}

function swapGraphics(){	
	var myGraphics = myDocument.allGraphics;
	for(var myCounter = myGraphics.length-1; myCounter >= 0; myCounter--){
		if(myGraphics[myCounter].itemLink.name == "30 Year Commerce CRG Logo.eps"){
				alert("see ya 30 year", "boom")
				myGraphics[myCounter].remove();
		}
		else 
			if (myGraphics[myCounter].itemLink.name == "CCRG_CWLogo.eps"){
				alert("see ya old logo", "pow")
				myGraphics[myCounter].itemLink.relink ("\\\\delphi\\gigas\\2 - Logos\\CRESLogos\\EPS\\commerce__cw_standard.eps");
				myGraphics[myCounter].itemLink.update();
			}
		else 
			if (myGraphics[myCounter].itemLink.name == "CCRG_CWLogo Reverse_BW_knockout.eps"){
			alert("see ya all white logo", "zing")
			myGraphics[myCounter].itemLink.relink ("\\\\delphi\\gigas\\2 - Logos\\CRESLogos\\CommerceLogos\\commerce_cw_white.ai");
			myGraphics[myCounter].itemLink.update();			
			}
	}
}

function changeAddress(){
	//Clear the find/change preferences.
	app.findTextPreferences = NothingEnum.nothing;
	app.changeTextPreferences = NothingEnum.nothing;
	//Set the find options.
	app.findChangeTextOptions.caseSensitive = false;
	app.findChangeTextOptions.includeFootnotes = false;
	app.findChangeTextOptions.includeHiddenLayers = false;
	app.findChangeTextOptions.includeLockedLayersForFind = false;
	app.findChangeTextOptions.includeLockedStoriesForFind = false;
	app.findChangeTextOptions.includeMasterPages = false;
	app.findChangeTextOptions.wholeWord = false;
	//Search the document for the string "copy" and change it to "text".
	app.findTextPreferences.findWhat = "commercecrg.com";
	app.changeTextPreferences.changeTo = "comre.com";
	app.documents.item(0).changeText();
	app.findTextPreferences.findWhat = "Commerce CRG";
	app.changeTextPreferences.changeTo = "Commerce Real Estate Solutions";
	app.documents.item(0).changeText();
	app.findTextPreferences.findWhat = "175 East 400 South, Suite 700 � Salt Lake City, Utah 84111";
	app.changeTextPreferences.changeTo = "170 South Main Street, Suite 1600 � Salt Lake City, Utah 84101";
	app.documents.item(0).changeText();
	app.findTextPreferences.findWhat = "175 East 400 South, Suite 700 | Salt Lake City, Utah 84111";
	app.changeTextPreferences.changeTo = "170 South Main Street, Suite 1600 | Salt Lake City, Utah 84101";
	app.documents.item(0).changeText();
	//Clear the find/change preferences after the search.
	app.findTextPreferences = NothingEnum.nothing;
	app.changeTextPreferences = NothingEnum.nothing;
}

Revision: 31411
at September 4, 2010 07:53 by landock


Initial Code
//myshit.jsx
//An InDesign CS3 JavaScript
/*  
@@@BUILDINFO@@@ "myshit.jsx" 1.0.0 14-September-2006
*/
//Adds labels to the graphics in the active document.
var myDocument = app.documents.item(0);

main();

function main(){
	if(app.documents.length != 0){
		if(app.documents.item(0).allGraphics.length != 0){
			swapGraphics();
			changeAddress();
		}
		else{
			alert("Document contains no graphics.");
		}
	}
	else{
		alert("Please open a document and try again.");
	}
}

function swapGraphics(){	
	var myGraphics = myDocument.allGraphics;
	for(var myCounter = myGraphics.length-1; myCounter >= 0; myCounter--){
		if(myGraphics[myCounter].itemLink.name == "30 Year Commerce CRG Logo.eps"){
				alert("see ya 30 year", "boom")
				myGraphics[myCounter].remove();
		}
		else 
			if (myGraphics[myCounter].itemLink.name == "CCRG_CWLogo.eps"){
				alert("see ya old logo", "pow")
				myGraphics[myCounter].itemLink.relink ("\\\\delphi\\gigas\\2 - Logos\\CRESLogos\\EPS\\commerce__cw_standard.eps");
				myGraphics[myCounter].itemLink.update();
			}
		else 
			if (myGraphics[myCounter].itemLink.name == "CCRG_CWLogo Reverse_BW_knockout.eps"){
			alert("see ya all white logo", "zing")
			myGraphics[myCounter].itemLink.relink ("\\\\delphi\\gigas\\2 - Logos\\CRESLogos\\CommerceLogos\\commerce_cw_white.ai");
			myGraphics[myCounter].itemLink.update();			
			}
	}
}

function changeAddress(){
	//Clear the find/change preferences.
	app.findTextPreferences = NothingEnum.nothing;
	app.changeTextPreferences = NothingEnum.nothing;
	//Set the find options.
	app.findChangeTextOptions.caseSensitive = false;
	app.findChangeTextOptions.includeFootnotes = false;
	app.findChangeTextOptions.includeHiddenLayers = false;
	app.findChangeTextOptions.includeLockedLayersForFind = false;
	app.findChangeTextOptions.includeLockedStoriesForFind = false;
	app.findChangeTextOptions.includeMasterPages = false;
	app.findChangeTextOptions.wholeWord = false;
	//Search the document for the string "copy" and change it to "text".
	app.findTextPreferences.findWhat = "commercecrg.com";
	app.changeTextPreferences.changeTo = "comre.com";
	app.documents.item(0).changeText();
	app.findTextPreferences.findWhat = "Commerce CRG";
	app.changeTextPreferences.changeTo = "Commerce Real Estate Solutions";
	app.documents.item(0).changeText();
	app.findTextPreferences.findWhat = "175 East 400 South, Suite 700 • Salt Lake City, Utah 84111";
	app.changeTextPreferences.changeTo = "170 South Main Street, Suite 1600 • Salt Lake City, Utah 84101";
	app.documents.item(0).changeText();
	app.findTextPreferences.findWhat = "175 East 400 South, Suite 700 | Salt Lake City, Utah 84111";
	app.changeTextPreferences.changeTo = "170 South Main Street, Suite 1600 | Salt Lake City, Utah 84101";
	app.documents.item(0).changeText();
	//Clear the find/change preferences after the search.
	app.findTextPreferences = NothingEnum.nothing;
	app.changeTextPreferences = NothingEnum.nothing;
}

Initial URL

                                

Initial Description

                                

Initial Title
InDesign template changer

Initial Tags

                                

Initial Language
JavaScript