Copy link to clipboard
Copied
Hi Everybody,
I have a photoshop file with existing text layers,
and i have a word or excel document.
I would like to know if its possible to make a script to copy from the word/excel and replace the text in each photoshop layers.
OR
i copy a paragraph from the word/excel and as i click on a text layers and run a script to change the text content.
Thanks a lot.
Copy link to clipboard
Copied
Please show something (screenshots or example *.psd + *.word/excel)
Because of there are too much possibilities.
Copy link to clipboard
Copied
Hi,
Thanks for your reply,
below is a small exemple of what i want to do.
on the left is the excel file and on the right the PSD.
As you can see the psd has 4 text layers and 4 rows in the excel file.
Instead of going in the excel copy the text, then double click on the text layer in photoshop and paste to change the text,
I want to know if any script can be done to do that.
Copy link to clipboard
Copied
Thank you for your example.
Yes. it is scriptable. But it depends the layers hierarchie.
Only one note: based on your example - IMO this should be the better way to go: Creating data-driven graphics in Photoshop
If so, have fun
Copy link to clipboard
Copied
Hi,
thanks for your help, i will try to learn the variable.
It may help me in my works>
Copy link to clipboard
Copied
Hi thanks
I need your help
Because this layer is opened to the document, the text can be replaced
this js code ,if using c# how to write this code? thanks
If the layer is a picture, how do I replace it? Using c#
Copy link to clipboard
Copied
using c# com interface create a selection region and replace text contents
thanks a lot
Copy link to clipboard
Copied
If you are using windows this C# program should work
N.B. There isn't much error checking though.
It prompts for the Excel file and expects the document open in Photoshop.
using System;
using System.Windows.Forms;
namespace CreateExcel
{
class Program
{
[STAThread]
static void Main(string[] args)
{
OpenFileDialog dlg = new OpenFileDialog();
dlg.Filter = "Excel Worksheets|*.xl*";
dlg.Multiselect = false;
string name;
if (dlg.ShowDialog() == DialogResult.OK)
{
name = dlg.FileName;
}
else
{
return;
}
var excelType = Type.GetTypeFromProgID("Excel.Application");
if (excelType == null) return;
dynamic excel = Activator.CreateInstance(excelType);
excel.Visible = false;
excel.Workbooks.Open(name);
string Location = excel.Cells(1, 1).Value;
string Age = excel.Cells(2, 1).Value;
string Address = excel.Cells(3, 1).Value;
string Name = excel.Cells(4, 1).Value;
excel.Quit();
dynamic app = Activator.CreateInstance(Type.GetTypeFromProgID("Photoshop.Application"));
if (app.Documents.Count == 0) return;
app.ActiveDocument.ActiveLayer = app.ActiveDocument.ArtLayers.GetByName("Location");
app.ActiveDocument.ActiveLayer.TextItem.Contents = Location;
app.ActiveDocument.ActiveLayer = app.ActiveDocument.ArtLayers.GetByName("Age");
app.ActiveDocument.ActiveLayer.TextItem.Contents = Age;
app.ActiveDocument.ActiveLayer = app.ActiveDocument.ArtLayers.GetByName("Address");
app.ActiveDocument.ActiveLayer.TextItem.Contents = Address;
app.ActiveDocument.ActiveLayer = app.ActiveDocument.ArtLayers.GetByName("Name");
app.ActiveDocument.ActiveLayer.TextItem.Contents = Name;
}
}
}
Copy link to clipboard
Copied
Hi,
thanks for the script,
acutuall im using mac, i will try to see if the script works on mac also.
The problem with the script is,
it will find the layers name in photoshop then change the text content,
what if i have more text layers with different name.
Is there a way to tell the script, the first row on the excel file , goes in the first text layer in photoshop>
the 2nd row to the 2nd text layer,
and it goes on like this.
thanks a lot
Copy link to clipboard
Copied
That code needs to be complied (Using Visual Studio) into an exe file so it will not work with a Mac. It is Windows only.
Copy link to clipboard
Copied
I have a simple js script you can use.
it runs thru all the layers in your photoshop file, if the layer is a text file
it uses the content of the array. It is far from perfect but it works.
Save the script as yourfilename.js
and run it in photoshop
#target photoshop; //array of what ever you need - but as many items in the array as text layers in the photoshop file var itemsAry=['Spain','lardtub','100','grandma on fire', 'nutbag','null','1000000']; var layers = app.activeDocument.layers; for (var i =0; i<layers.length; i++) { if (layers.kind == "LayerKind.TEXT") { layers.textItem.contents=itemsAry } }js and photshop test file for download
https://www.dropbox.com/s/26lhgfha7jhoco5/fucj-year-psd-text.zip?dl=0
Copy link to clipboard
Copied
Allrighty.
I made a script that loads a .txt file and split it into an array
Then the script finds all Artborads/Groups and loops thru all textlayers
and fill the text content with the array.
https://www.dropbox.com/s/lur2xo8o6mr4qr9/from-txt-to-psd.zip?dl=0https://www.dropbox.com/s/lur2xo8o6mr4qr9/from-txt-to-psd.zip?dl=0
// to get line breaks in the text file you need to insert ( %0D%0A ).
Im line one %0D%0A i am line tow resoults in
Im line one
I am line tow