tell application “Adobe InDesign 2020”
set table1 to table 1 of story 1 of document 1
set table2 to table 1 of story 1 of document 2
–assuming the destination cell is empty
duplicate text of cell 1 of table1 to after last insertion point of cell 1 of table2
end tell
The easy way is to use the copy command.
But you have to set the clipboard behavior at first.
Try this:
tell application id "InDn"
activate
if class of selection is not in {cell, column, table} then return beep
tell clipboard preferences to set prefer styled text when pasting to true
set userButton to button returned of (display dialog "Do you want to copy or paste the table cells?" buttons {"Cancel", "Copy", "Paste"} default button 2 cancel button 1)
if userButton = "Copy" then copy
if userButton = "Paste" then paste
end tell
Well, this is odd. I was preparing to try those two suggestions, and pasted them both in to a new Script Debugger document.
I had to make a few tweaks (including changing a “-” to “–”) so I could see if they would compile.
The compile failed on the word “the” in the commented line.
I pasted the same script into Script Editor and got the same error.
I removed the commented line and it compiled.
What is happening here?
tell application "Adobe InDesign CS6"
activate
if class of selection is not in {cell, column, table} then return beep
tell clipboard preferences to set prefer styled text when pasting to true
copy
paste
end tell
tell application "Adobe InDesign CS6"
set table1 to table 1 of story 1 of document 1
set table2 to table 1 of story 1 of document 2
–- assuming the destination cell is empty
duplicate text of cell 1 of table1 to after last insertion point of cell 1 of table 2
end tell
→ Script Debugger 7.0.13 (7A125)
→ Mac OS 10.11.6 (15G22010)
→ InDesign CS6 (8.1)
You definitely put me on the right path, thanks! Here’s what I came up with (minus so very specific commands)
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
--Duplicate a table from one document to an empty table in a second document.
tell application "Adobe InDesign CS6"
set allSourceRows to every row of sourceTable
repeat with sourceRow in allSourceRows
set sourceCells to every cell of sourceRow
set thisRowsCells to {}
repeat with thisCell in sourceCells
set cellLabel to label of thisCell
set fillColor to name of fill color of thisCell
set destinationCell to (cell 1 of tableDest whose label is cellLabel)
set the end of thisRowsCells to destinationCell
set contents of destinationCell to ""
duplicate text of thisCell to after last insertion point of destinationCell
set fill color of destinationCell to fillColor
end repeat
end repeat
end tell