Re: From tab text to Excel
Re: From tab text to Excel
- Subject: Re: From tab text to Excel
- From: Eric Geoffroy <email@hidden>
- Date: Tue, 12 Apr 2005 11:36:18 -0700
Wow. I was going wrong in three different directions at once. Thanks for suffering through that.
Excel version is v.X, and seems to accept either r2c6 or F2 format. We'll see what happens when I distribute this script. I only could find the Applescript guide for Excel 2004 on the web. If there was one for v.X it's been hidden.
First mistake was tying my hands with a tab file. Excel wanted a list. So I'm giving it a list. (straight of of FMPro 6)
Next, I was foolishly trying to write the three tab delim items to columns when I really wanted rows.
Based on Paul's helpful hints, I was able to figure it out finally and feel a little less dim now. Self-flame off.
tell application "Microsoft Excel"
repeat with x from 1 to count mlist
set r to (0 + x)
set L to "r" & r & "c1:r" & r & "c4" as string
set Value of Range L of Sheet 1 of Workbook "Workbook3" to item x of my mlist
end repeat
end tell
I also got to try out Matt Neuberg's speedy list access trick for the first time-- using "my" when referencing a list. There's no explanation why it works, but it seems noticeable to me.
Thanks again!
On Apr 11, 2005, at 6:54 PM, Paul Berkowitz wrote:
On 4/11/05 4:51 PM, "Eric Geoffroy" <email@hidden> wrote:
I'm going to add a repeat to this once it's working.
I have a tab delim text file, but putting the items into a worksheet I'm stymied. Some of the text in the file is separated by a space, but I'm only concerned with the tab. I mucked around with text item delimter.
set emmlyst to read EMMlog using delimiter {ASCII character 10} --(So far so good. the first line works. yay!)
tell application "Microsoft Excel"
set Value of Range "B1:B3" of Sheet 1 of Workbook "Workbook1" to paragraph 1 of item 1 of emmlyst
end tell
Well that didn't work. I realize I made a huge assumption that the tabs would be read into Excel. I'm not really an optimist usually.
Do I need to be granular about this and fill each cell with each word.
But by using delimiter {ASCII character 10} you've already made a list of paragraphs. (If your text file was an LF line-ending text.) Also I'm not quite sure why you've put list brackets around ASCII character 10. That would be for 'using delimiters' (plural). If you're 'using delimiter' (singular) the argument is a string. Maybe it coerces to a string. Anyway, why not
set r to read EMMlog
set emmlyst to paragraphs of r
tell application "Microsoft Excel"
set Value of Range "R1C2" of Sheet 1 of Workbook "Workbook1" to item 1 of emmlyst --NOT 'paragraph of'
end tell
You've used Range "B1:B3". First of all, that's a column with three rows. You can't set its value to one string. You have to set it to a list of a list of 3 strings. Furthermore, Excel X and earlier (which you're using) use the "R1C1" style of address. (Excel 2004 uses "A1" style.) So if you really wanted to set three cells in the column at once, it would be:
set Value of Range "R1C2:R3C2" of Sheet 1 of Workbook "Workbook1" to {{item 1 of emmlyst, item 2 of emmlyst, item 3 of emmlyst}}
Are you trying to put three separate words, one word in each cell? If so, you need to do a lot more parsing, using {" "} as text delimiters.
Otherwise, use "R1C2" (i.e. cell "B1") alone to store the first paragraph.
Maybe you'd better explain what you're trying to do first.
--
Paul Berkowitz
_______________________________________________
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
Eric Geoffroy
Media Producer
Peachpit Press
(510) 524-2178 x214
_______________________________________________
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