Hi all,
I saw a request for dymo label printing here long ago, and I finally figured out how to write a script that would print the address listed in the currently selected sheet to the dymo. I thought others would be interested in it. It works for me with version 7.5 of the dymo software, available on their website. Please tell me if anyone has any comments…it expects the dymo software to be in its default location, and I hard coded the label choice, but it should otherwise be self-explanatory.
best,
Eric
---print label of selected sheet rows using dymo label printer version 7.5 or higher
--
----This script will pull the contents of the first column of the selected sheet that contains the following string as part of its name
property target_column : "address"
tell application "DEVONthink Pro"
try
if not (exists think window 1) then error "No window is open."
set this_window to think window 1
set the_selection to the selection
set the_sheet to (the first item of the_selection)
set the_cols to the columns of the_sheet
set address_col to 0
set counter to 1
repeat with this_col in the_cols
if (this_col contains target_column) then set address_col to counter + 1
set counter to counter + 1
end repeat
if (address_col = 0) then error "please make sure you have a column containing the word '" * target_column & "' "
tell this_window
set selRow to selected row
if selected row ≤ 0 then error "Please select a row in a sheet."
set the_address to get cell at row selRow column address_col
end tell
on error error_message number error_number
if the error_number is not -128 then
try
display alert "DEVONthink Pro" message error_message as warning
on error number error_number
if error_number is -1708 then display dialog error_message buttons {"OK"} default button 1
end try
end if
end try
end tell
try
tell application "DYMO Label"
--activate
loadPlugin name "Label Editor"
set label to "/Applications/DYMO Label/Label Files/shipping (30256).dlf"
openLabel in label
end tell
tell application "DYMO Label"
tell current plugin
set (content of (print object named "ADDRESS")) to the_address
end tell
redrawLabel
printLabel2
end tell
end try