• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to create a document?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to create a document?


  • Subject: Re: How to create a document?
  • From: Brian Christmas <email@hidden>
  • Date: Sun, 05 Jun 2016 15:47:19 +1000

G’day

I use this handler to create a new TextEdit document.

Regards

Santa


tell application "TextEdit"
repeat
activate
try
do shell script ("sleep 0.1")
tell application "System Events" to tell process "TextEdit"
try
repeat until (exists menu item "New" of menu 1 of menu bar item "File" of menu bar 1)
do shell script ("sleep 0.1")
end repeat
click menu item "New" of menu 1 of menu bar item "File" of menu bar 1
exit repeat
on error errmsg number errnum
if errnum = -1719 or errnum = -25211 then
set my assistTrial to false
exit repeat
end if
end try
end tell
on error errmsg number errnum
set my assistTrial to false
my displayError("Text Edit Start error " & errmsg & " number " & errnum as text)
end try
end repeat


On 5 Jun 2016, at 1:32 PM, Mitchell L Model <email@hidden> wrote:

This sounds like something completely trivial, but my experiments show it to be  fraught with complications.

All I want to do is create a new document in TextEdit, Script Editor, and Script Debugger. It doesn’t need to be saved, but it is OK if it is saved.

Warning: if you approach this you may find yourself creating documents that can’t be saved or closed, or even backed up. If you do, you can execute a script that does “close front doc without saving”.

I have three lines of code that behave differently in the three applications mentioned above, but I’d rather see a real solution rather than providing my code to be debugged.

See https://discussions.apple.com/message/30269814 for my first attempt at resolving this problem, in the context of TextEdit. (I still haven’t been able to get it to work, despite the help I got on that page.)






 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >How to create a document? (From: Mitchell L Model <email@hidden>)

  • Prev by Date: How to create a document?
  • Next by Date: Re: How to create a document?
  • Previous by thread: How to create a document?
  • Next by thread: Re: How to create a document?
  • Index(es):
    • Date
    • Thread