• 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: String character offset in excel cell string value
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: String character offset in excel cell string value


  • Subject: Re: String character offset in excel cell string value
  • From: cheshirekat <email@hidden>
  • Date: Wed, 20 Oct 2004 16:16:02 -0600

On Wed, Oct 20, 20046:05 PM, the following words from Stephanos
Piperoglou email@hidden, emerged from a plethora of SPAM ...

>peter boardman wrote:
>
>>>I'm trying to parse a string contained in an Excel workbook
>>>[...}
>>>rec_name is a string. Offset is a method of string. Why is access not
>allowed?
>>>
>>>
>>
>>obviously offset is being interpreted by Excel somehow. Take it outside
>the tell block?
>>
>>
>
>Thanks that did it, though it did mess up my code a bit (a lot initially
>because I rewrote it thinking that variables are scoped inside tell
>blocks, which they're not. AppleScript is weird - but in a good way :-).
>Kind of like perl only you can actually read your own code).

Is this with Excel X or 2004?

I find it easier to include it in a subroutine which avoids conflicts
with certain keywords. If I need to perform more actions/manipulations of
that cell, I can always add another subroutine. I usually find it easier
to read my scripts at a later time when I use subroutines because I use
them for the majority of my scripts.

Here is an "offset" example, where I use a subroutine...

to extractTheState from t
  set the fifthEnd to character -5 of the t
  if the fifthEnd is "-" then
    set the endChar to 12
  else
    set the endChar to 6
  end if
  set the commaOff to the offset of ", " in the t
  set the startChar to the commaOff + 2
  set the tList to the characters of t
  set the stateTxt to (characters startChar through -endChar of the t) as text
  return the stateTxt
end extractTheState

tell application "Microsoft Excel"
  set the targetC to the ActiveCell
  set the textExtract to the Value of the targetC
  --> "New York, New York 77777-1234"
  set the stateTxt to extractTheState of me from (the textExtract)
end tell

cheshirekat
--
Music and silence ... combine strongly because music is done with silence,
and silence is full of music.

-  Marcel Marceau, US News & World Report 23 Feb 87

* 867 PowerBook G4 * OS X 10.2.8 * 768 MB Ram *
* Addictions: iTunes * AppleScript * iLife 4 * FileMaker Pro *

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Re: String character offset in excel cell string value (From: Stephanos Piperoglou <email@hidden>)

  • Prev by Date: Re: Of clip2gif, clipboard, and OS 10.3
  • Next by Date: Re: Seeking "non-programmer's" AppleScript reference
  • Previous by thread: Re: String character offset in excel cell string value
  • Next by thread: Excel cell background color / Dictionary lookup
  • Index(es):
    • Date
    • Thread