• 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: Checking for return or enter in an Excel document
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Checking for return or enter in an Excel document


  • Subject: Re: Checking for return or enter in an Excel document
  • From: Mads Fog Albrechtslund <email@hidden>
  • Date: Wed, 23 May 2012 12:56:08 +0200

Hi Bert

Disregard earlier post, there was some typos in the Script.
Updated and working script below.

Try this, a modified version of Jan's script.
But using "ASObjC Runner" to do a search and replace in the cells.
Download "ASObjC Runner" here: http://www.macosxautomation.com/applescript/apps/runner.html

set TheReturn to ASCII character 13
set TheReplacement to " "

tell application "Microsoft Excel"
set UsedRange to used range of active sheet
repeat with theCell from 1 to (count cells of UsedRange)
set theCellValue to value of cell theCell of UsedRange
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 value of cell theCell of UsedRange to theString
end if
end repeat
end tell

PS: Sorry to Jan, for the earlier "direct-reply".

Best Regards,
Mads Fog Albrechtslund
Denmark

On 23/05/2012, at 12.25, Jan-Bultereys wrote:

hi Bert,

I am not aware a return/enter can be added in a cell...
But let presume that's the case the following code will give you some direction.
Just replace theA to TheReturn and give it a try

--- return
set TheReturn to ASCII character 13
--- character a just for testing
set theA to ASCII character 65
tell application "Microsoft Excel"
set UsedRange to used range of active sheet
repeat with i from 1 to (count cells of UsedRange)
set theCell to value of cell i of UsedRange
if theCell contains theA then
display dialog "match"
end if
end repeat
end tell

 best regards,jan



On 23 mei 2012, at 09:47, Bert Groeneveld wrote:

Is there an Applescript way to loop through all the cels of an Excel document and check if a cel contains a return/enter?

Background info: I have a script that handles Excel documents for a certain purpose. It tells Microsoft Excel to save the document as a text delimited file for further processing. If a cel contains a return I get wrong text file output (the extra return generates an unwanted new line in the text file).

I hope someone can post example code.

Thanks in advance.

 _______________________________________________
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: Checking for return or enter in an Excel document
      • From: Stan Cleveland <email@hidden>
References: 
 >Checking for return or enter in an Excel document (From: Bert Groeneveld <email@hidden>)
 >Re: Checking for return or enter in an Excel document (From: Jan-Bultereys <email@hidden>)

  • Prev by Date: Re: Checking for return or enter in an Excel document
  • Next by Date: Re: Filtering Out Missing Value
  • Previous by thread: Re: Checking for return or enter in an Excel document
  • Next by thread: Re: Checking for return or enter in an Excel document
  • Index(es):
    • Date
    • Thread