Actually, I answered this two days ago where you first asked this, Peter -
on Rick Schaut's blog. Did you not go back to check?
I include there how you'd make a footnote at somewhere other than the cursor
location in the document, for example at the end of the first paragraph:
tell application "Microsoft Word"
set oDoc to active document
set t to text object of paragraph 1 of oDoc
set f to make new footnote at t
set content of text object of f to "Here's another footnote."
end tell
There's a lot more info there. Instead of my repeating it, just go there to
check
http://blogs.msdn.com/rick_schaut/archive/2004/06/25/165528.aspx#FeedBack
You should not find it frustrating that you can't get 'selection of document
1', as you certainly can in some applications. You (all of us) need to
spend time checking things in the dictionary. Word's Object Model does not
allow for selections in different documents. There is only one selection in
the application - and that's in the front document. (You can see this even
in the UI: when you click on another doc, the selection in the formerly
front doc disappears.) So 'selection' is a property only of 'application' -
where you'll find it. If it were also a property of 'document', then every
single open doc could have it's own selection. (Some apps do allow this.) I
think that things are probably the way they are to emphasize that using
'selection' is something that mimics a user in the UI - there's only one
selection, and that's in the front window. It's not in fact the best way to
control Word. You should spend some time learning about 'text range' : the
most essential object in all of Word's scripting and (as 'Range') VBA. In
AppleScript, it's usually accessed as the 'text object' property of all
sorts of things - document, paragraph, etc. You can adjust properties, and
make footnotes, at any range in any document - it doesn't have to be in the
front, and nothing needs to be selected.
It's _very_ sensible of the Word developer to have used 'content' rather
than 'contents'. Many applications run into trouble when they use 'contents'
instead, since it's also an AppleScript language keyword that simply
dereferences a reference. (For example, if you script
set the List to {1,2,3}
set x to 3
repeat with anItem in theList
if anItem = x then
display dialog (x as string)
end if
end repeat
you'll never get that dialog. But if you use
if (contents of anItem) = x
then you will.)
What this means is that in some applications, when you ask for 'contents' of
something, you just get the same thing back again. That's why you got the
error. (In AppleScript Studio, you have to ask for 'contents of contents' to
actually get what you want!) By making a distinction between AppleScript's
'contents' and Word's own 'content' property, you'll never hit that
conflict. Because 'contents' is an AppleScript language keyword, it compiles
fine in all times and places and tell blocks. That's not Word's fault. The
fact that something compiles does not mean it's the correct term. (Not only
do you have to watch out for AppleScript keywords, but also for scripting
addition commands, which will also compile.)
Just make no assumptions, and study the dictionary. It's hard-going, but
eventually you start to get the strange logic of it all.
But learning about Word's 'find' and 'replace' commands are among the most
knotty complicated things in the object model. Do check up in the VBE Help,
and also in the VBA pages at
http://www.word.mvps.org/ . (You have to
refresh a couple of times for each page there in Safari, or else use IE.)
--
Paul Berkowitz
MVP Entourage
Entourage FAQ Page: <
http://www.entourage.mvps.org/faq/index.html>
AppleScripts for Entourage: <
http://macscripter.net/scriptbuilders/>
Please "Reply To Newsgroup" to reply to this message. Emails will be
ignored.
PLEASE always state which version of Entourage you are using - **2004**, X
or 2001. It's often impossible to answer your questions otherwise.