Hi all, I’ve been building little Applescript projects to speed up my workflow on various design tasks for about year now and this is my first time I’ve had to resort to making my own thread here instead of poring over other people’s.
My goal to take the text of an Excel cell and transfer it into an InDesign document, preserving all the instances of bold and italic text, preferably without coding in copying/pasting keyboard shortcuts.
I’d include some of my failed attempts to make this work, but I don’t think any of them were even close.
Most of my morning was spent trying to find out how one would write in import options for placing one cel of an Excel file into a document (like you can in the visual interface) but I couldn’t find a single thing on it.
I’ve figured something out: Setting Indesign’s properties to ‘paste all information’, copying a cell from Excel onto the clipboard, using ‘paste’ in InDesign to create a whole new text frame then manipulating that into the position I need.
How my solution looks (for further refinement suggestions or for anyone googling the same problem). In order to actually reference the pasted textbook I needed to create a new empty layer to house it and pull it from there. If anyone knows a more efficient way I’d be interested!
tell application "Microsoft Excel"
tell mySpreadsheet
goto reference ("A1")
tell application "System Events"
tell process "Microsoft Excel"
keystroke "c" using command down
delay 0.2 -- wait for key stroke entry
end tell
end tell
end tell
end tell
tell application "Adobe InDesign CC 2018"
set Pastelayer to make layer at myDocument with properties {name:"Pasted"}
paste
set pastedTextBox to first text frame of Pastelayer
move pastedTextBox to layer "Layer 1" of myDocument
delete Pastelayer
set geometric bounds of pastedTextBox to {whatever}
end tell
EDIT True to previous experiences, I’m finding the keystroke coding method massively unreliable with the clipboard only updating with what it’s supposed to a certain percent of the time. Does anyone know a better way to get the data I need onto the clipboard?