• 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: Passing MS Word object specs (Larry the O)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Passing MS Word object specs (Larry the O)


  • Subject: Re: Passing MS Word object specs (Larry the O)
  • From: kai <email@hidden>
  • Date: Tue, 20 Mar 2007 15:11:37 +0000


On 20 Mar 2007, at 00:56, Larry the O wrote:

on getStoryParts(wholeStory)
set wholeStoryText to content of wholeStory
if paragraph 1 of wholeStoryText is "" then
beep
end if
end getStoryParts

The script crashes in getStoryParts with a message saying "Can't get paragraph 1 of missing value."
The last command in the log before the crash message is where it tries to get the content of wholeStory, for which the result is "missing value."
I also tried getting the content of the text object of wholeStory, with identical results.


So, it would seem that the problem is not wholeStory getting passed correctly, since the other routines seem to be getting it, but, on the other hand, this works fine:

tell application "Microsoft Word"
set wholeStory to (create range active document start 0 end (count of characters in active document))
set wholeText to content of wholeStory
if paragraph 2 of wholeText is "" then --paragraph 2 is blank
display dialog "we got nothin!" --this dialog comes up as expected
else
display dialog "We got text!"
end if
end tell


I'm SO confused.

Perfectly understandable, Larry - but there's one significant difference between the code within your 'getStoryParts' handler and the in-line version immediately above. In the latter, the entire code is within an application tell statement, while that in the separate handler isn't.


When the handler code is compiled, the word 'content' is interpreted as a variable - which causes problems at runtime. In the in-line version, the same word is interpreted, this time correctly, as a Word- specific property of the referenced text range. (When you compile the code in Script Editor, check out the way in which the word is visibly formatted in each case; you should see a difference.)

You should be able to fix this in a number of ways, including...

Adding a tell statement:
-----------------
on getStoryParts(wholeStory)
	tell application "Microsoft Word" to ¬
		set wholeStoryText to content of wholeStory
	if paragraph 1 of wholeStoryText is "" then
		beep
	end if
end getStoryParts
-----------------

Inserting a 'using terms from' statement (so the code is compiled correctly):
-----------------
on getStoryParts(wholeStory)
using terms from application "Microsoft Word"
set wholeStoryText to content of wholeStory
end using terms from
if paragraph 1 of wholeStoryText is "" then
beep
end if
end getStoryParts
-----------------


Using the raw code for any application-specific term(s):
-----------------
on getStoryParts(wholeStory)
	set wholeStoryText to «class 1650» of wholeStory
	if paragraph 1 of wholeStoryText is "" then
		beep
	end if
end getStoryParts
-----------------

---
kai


_______________________________________________ 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: 
 >Re: Passing MS Word object specs (Larry the O) (From: Olof Hellman <email@hidden>)
 >Re: Passing MS Word object specs (Larry the O) (From: Larry the O <email@hidden>)

  • Prev by Date: Re: dimensions of visible monitor
  • Next by Date: Passing MS Word object specs (Larry the O)
  • Previous by thread: Re: Passing MS Word object specs (Larry the O)
  • Next by thread: Passing MS Word object specs (Larry the O)
  • Index(es):
    • Date
    • Thread