• 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
How to create a document?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to create a document?


  • Subject: How to create a document?
  • From: Mitchell L Model <email@hidden>
  • Date: Mon, 18 Jul 2016 08:39:56 -0400

I provoked a discussion in Vol 13, issues 236-250 by asking "How to create a document?" (with specific reference to scripting TextEdit). I believe the conclusive entry in this challenge was in issue 242:

set testFile to "This is a test.txt"
set thePath to ((path to desktop as text) & testFile) as «class furl»
tell application "TextEdit"
activate
make new document
tell document 1
close it saving yes saving in thePath
end tell
open thePath
# Now we may work as we want upon the document
end tell

Yvan KOENIG running El Capitan 10.11.5 in French (VALLAURIS, France) dimanche 5 juin 2016 20:39:06


I used this approach for a while, but ran into related problems. In a rare out-of-the box thought I realized that we were all too fixated on AppleScript, unsurprisingly given that this is the AppleScript list. The following script performs flawlessly and works whether the file exists or not:

to createNewDocument(theApplication, thePath)
do shell script "touch " & quoted form of the POSIX path of thePath
tell application theApplication to open thePath
end createNewDocument

TaDa!


 _______________________________________________
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

  • Follow-Ups:
    • Re: How to create a document?
      • From: Shane Stanley <email@hidden>
  • Prev by Date: Re: need explanation for trivial Safari script behavior
  • Next by Date: Re: How to create a document?
  • Previous by thread: [ANN] Script Debugger 6 ASObjC Resources
  • Next by thread: Re: How to create a document?
  • Index(es):
    • Date
    • Thread