• 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: Larry the O <email@hidden>
  • Date: Mon, 19 Mar 2007 17:56:07 -0700

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


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

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