• 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: AS and Excel
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AS and Excel


  • Subject: Re: AS and Excel
  • From: "koenig.yvan" <email@hidden>
  • Date: Tue, 20 Aug 2013 17:34:34 +0200


Le 20/08/2013 à 15:24, Thomas Fischer <email@hidden> a écrit :

Hello Yvan,

I don't have a complete solution, but probably others can help.
I found two problems:
1. Microsoft Excel seems to like to get the name of the workbook as string
2. I found no way to get anything like
every cell in range ("A1:A100") whose value is not ""
to work with Excel.
Up to now I have:

tell application "Microsoft Excel"
set testFile to choose file "PLease select the Excel Workbook!"
set fileName to testFile as string
set newWorkbook to open workbook workbook file name fileName
set theSheet to sheet 1
set theResult to {}
set theCells to (every cell in range ("A1:A100"))
repeat with theCell in theCells
if the value of theCell ≠ "" then copy the the value of theCell to the end of theResult
end repeat
theResult
end tell

Best
Thomas


Thanks.

As I don't know the real height of the table I assume that it would be safe to edit the instruction defining the range 

set testFile to choose file "PLease select the Excel Workbook!"
tell application "Microsoft Excel"
set fileName to testFile as string
set newWorkbook to open workbook workbook file name fileName
set theSheet to sheet 1
set theResult to {}
set theCells to (every cell in range ("A1:A" & last row))
repeat with theCell in theCells
if the value of theCell ≠ "" then copy the value of theCell to the end of theResult
end repeat
theResult
end tell

If there is really no built in substitute to whose value is not ""
We may drop the loop cleaning the list because the code using the returned list is :

if aValue is in theResult then
# do your duty
end if

and aValue is a folder name so it's certainly not empty.

I assume that it would be OK with :

set testFile to choose file "PLease select the Excel Workbook!"
tell application "Microsoft Excel"
set fileName to testFile as string
set newWorkbook to open workbook workbook file name fileName
set theSheet to sheet 1
set theResult to (value of every cell in range ("A1:A" & last row))
end tell

What's the need for set theSheet to sheet 1

If I missed nothing the variable theSheet is defined but isn't used.

I will wait until tomorrow in hope that somebody will have 

KOENIG Yvan (VALLAURIS, France) mardi 20 août 2013 17:34:24



 _______________________________________________
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: AS and Excel
      • From: "koenig.yvan" <email@hidden>
    • Re: AS and Excel
      • From: 2551 <email@hidden>
References: 
 >AS and Excel (From: "koenig.yvan" <email@hidden>)
 >Re: AS and Excel (From: Thomas Fischer <email@hidden>)

  • Prev by Date: Re: AS and Excel
  • Next by Date: Re: AS and Excel
  • Previous by thread: Re: AS and Excel
  • Next by thread: Re: AS and Excel
  • Index(es):
    • Date
    • Thread