• 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: Yvan KOENIG <email@hidden>
  • Date: Sun, 05 Jun 2016 18:06:59 +0200

Oops !
One comment was misplaced. Better with :
tell application "TextEdit"
activate
set doc to make new document
log doc --> (*document Sans titre*)
set the name of doc to "Test17"
log doc -- (*document Sans titre*)
try
set the text of doc to "1"
--> set every text of document "Sans titre" to "1"
on error errMsg number errNbr
log errMsg (*Erreur dans TextEdit : Il est impossible de régler document "Sans titre" à "1".*)
end try
set doc to document 1
log doc --> (*document Test17*)
set the text of doc to "1"
--> set every text of document "Test17" to "1"
end tell

Here is a more efficient scheme.

set testFile to "This is a test.txt"
--set thePath to (path to desktop as text) & testFile
--set posixPath to POSIX path of thePath
set posixPath to POSIX path of ((path to desktop as text) & testFile)
tell application "TextEdit"
activate
--make new document with properties {path: posixPath} # BEURK , it set the window name but doesn't set the fileName.
--make new document with properties {path: posixPath, name:testFile} # BEURK, it behaves the same !
make new document with properties {path:posixPath} # doesn't set the fileName but correctly set the path
tell document 1
set its text to "one two three"
set its name to testFile
# no need to save here, AutoSave did the job !
end tell
end tell

I left two disabled make to describe different behaviors.


Yvan KOENIG running El Capitan 10.11.5 in French (VALLAURIS, France) dimanche 5 juin 2016 18:04:28



 _______________________________________________
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: Bruce Robertson <email@hidden>
References: 
 >Re: How to create a document? (From: Mitchell L Model <email@hidden>)

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