Problem with ‘make new attachment’ ?

The following script fails making an image attachment if you specify ‘end’ for the text of the window of a rich text doc. If that’s normal then fine. However, you can ‘make new paragraph’ and specify ‘end’ and that works fine.

tell application id "com.devon-technologies.thinkpro2"
	tell text of think window 1
		set theFile to alias "Macintosh HD:Users:yourname:SomePath:SomeImage.jpeg"
		make new paragraph with data "Whatever" at end -—This works
		make new attachment with properties {file name:theFile} at last character --This works
		make new attachment with properties {file name:theFile} at end --This does not work			
	end tell
end tell

In my ‘Daily Journal’ script located in this forum, if I substitute ‘end’ for ‘last paragraph’ to place the image attachment, DTPO v. 2.7.2 crashes.

This is no big problem for me, it’s just a head’s up on a potential problem.

What OS?

I’m on 10.8.5 and it’s almost working as expected. Unexpectedly, it attaches the image before the “Whatever” paragraph but isn’t crashing.
Send the crash report to Support Ticket. Thanks (and thanks for posting the code). :smiley:

When OS X is told to add an attachment to an RTF it turns the file into a package and includes the attachments inside the package. So this is sufficient. Your “make new paragraph” code already positioned the cursor at end-of-text.

make new attachment with properties {file name:theFile}

no “end” in sight :smiley:

I totally follow the logic, korm but there’s definitely something wrong when this line of code…

make new attachment at end of paragraph 1 with properties {file name:theFile} --This does not work 

```puts the attachment at the beginning of the paragraph. Are you not seeing this on 10.9?

I get an Apple event handler error and nothing is added anywhere (on 10.9).

Thanks for taking the time to look at this guys. I’m running OS 10.9 Mavericks on a late 2012 iMac with fusion drive. korm, It didn’t even occur to me to not specify the attachment location! That works, but what works best for me is to specify ‘at last character’ for the position. However, I still think there’s a problem with the handling of the placement of an attachment. Of course, that may very well be Apple’s fault. In any case, I’m pretty sure we’ll all survive this! :slight_smile:

Interesting… BTW, this does work

make new attachment at end of paragraphs with properties {file name:theFile}

I’ll send Criss a link to this discussion.