Somehow, this still isn't working. Here's some code. filesToProcess is a list of dropped files.
on commonCode()
getEditorInitials()
--main loop to work through list of files repeat with s from 1 to count of items in filesToProcess
set currentStory to item s of filesToProcess tell application "Microsoft Word" activate open file currentStory set wholeStory to (create range active document start 0 end (count of characters in active document)) end tell
my formatStoryText(wholeStory) my errorCheck(wholeStory) my getStoryParts(wholeStory) end repeat end commonCode()
on editorInitials() <commands that work dandy> .... end editorInitials
on formatStoryText(wholeStory) <some commands that seem to work fine> ..... end formatStoryText
on errorCheck(wholeStory) <more commands that work fine> ... end errorCheck
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.
Thanks,
Larry
10:01 PM, Olof Hellman wrote:
On Mar 14, 2007, at 8:08 PM, Larry the O wrote:
It compiles OK, but I get an error when it tries to do the subroutine call, and I would bet that it's because AppleScript can't grok the chunk of data Word is handing it.
Is there a way to do this or is AS just incapable of hacking the wacky world of Microsoft?
Well, the VB-ish scripting of Mac Office is indeed wacky, but adding 'my' to your script will at least get you a successful subroutine call:
on processText(wholeStory) beep end processText
tell application "Microsoft Word" set wholeStory to (create range active document start 0 end (count of characters in active document)) my processText(wholeStory) end tell
You'll probably need another tell block inside the processText code if you want to do anything useful with wholeStory.
- Olof Hellman Microsoft MacBU
|