Re: Checking for return or enter in an Excel document
Re: Checking for return or enter in an Excel document
- Subject: Re: Checking for return or enter in an Excel document
- From: Stan Cleveland <email@hidden>
- Date: Wed, 23 May 2012 14:06:47 -0700
On May 23, 2012, at 3:56 AM, Mads Fog Albrechtslund wrote: Try this, a modified version of Jan's script.
Accessing data cell by cell in Excel is somewhat slow. It's much faster to grab the entire contents of the document, cycle through the resulting list of lists, then write all the data back to Excel after fixing the return characters.
With that in mind, below is another modification of Jan's/Mads' script. This version also eliminates the nesting of tell application commands, which is best to avoid.
Stan C.
set TheReturn to ASCII character 13 set TheReplacement to " " tell application "Microsoft Excel" set sheetData to formula of used range of active sheet -- grab all data from Excel end tellrepeat with r from 1 to (length of sheetData) set thisRow to item r of sheetData repeat with c from 1 to (length of thisRow) set theCellValue to item c of thisRow if theCellValue contains TheReturn then tell application "ASObjC Runner" set theString to replace string (ASCII character 13) in item theCellValue replacing with TheReplacement end tell set item c of item r of sheetData to theString -- update the cell end if end repeat end repeat tell application "Microsoft Excel" set formula of used range of active sheet to sheetData -- push all data back to Excel end tell
|
_______________________________________________
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