• 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: Excel Sheets to CSV
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Excel Sheets to CSV


  • Subject: Re: Excel Sheets to CSV
  • From: Jan-Bultereys <email@hidden>
  • Date: Wed, 15 Jun 2011 20:50:54 +0200

hi scott,

try this: 
close active workbook saving no

best regards,jan



On 15 Jun 2011, at 14:25, Scott Wilcox wrote:

Sadly that didn't work, I'm still getting a 'Do you want to save the changes you made to [filename here]?

Thank you for the reply though!

On 15 Jun 2011, at 13:21, Leonid Bogdanov wrote:

Hello, Scott!

  Try this one. It should save worksheets in CSV files with overwriting existing ones. Don't know about saving in UTF-8.
  Maybe you just can use 'iconv' for encoding conversions.


set excelDirectory to "Macintosh HD:Users:scott:Downloads:Excel:"

set outputDirectory to "Macintosh HD:Users:scott:Downloads:Excel:converted"

tell application "Microsoft Excel"

set theWorkbook to open workbook workbook file name (excelDirectory & "excel.xls")

set maxCount to count worksheets of theWorkbook

repeat with i from 1 to maxCount

set theWorksheet to worksheet i of theWorkbook

set worksheetName to name of theWorksheet 

save as theWorksheet filename (outputDirectory & ":" & worksheetName & ".csv") file format CSV file format with overwrite

end repeat

close theWorkbook saving no

end tell


15 June 2011, 13:05 letter from Scott Wilcox <email@hidden>:
Hi folks,

I've written an Applescript that is almost working how I want it to. There are a couple more things that I can't seem to get quite right.

-- Paths to Excel file and output directory
set excelDirectory to "Macintosh HD:Users:scott:Downloads:Excel:"
set outputDirectory to "Macintosh HD:Users:scott:Downloads:Excel:converted"

tell application "Microsoft Excel"

activate

set theWorkbook to open workbook workbook file name excelDirectory & "excel.xls"

set maxCount to count of worksheets of theWorkbook

repeat with i from 1 to maxCount

set theWorkbook to open workbook workbook file name excelDirectory & "excel.xls"

set theWorksheet to worksheet i of theWorkbook

set worksheetName to name of theWorksheet

activate object worksheet worksheetName

save as theWorksheet filename (outputDirectory & ":" & worksheetName & ".csv") file format CSV file format

close active workbook

end repeat

end tell

The script runs through and processes the files and exports them to CSV. However, I need to UTF8 encode the files and preferably prevent the 'save changes' prompt from happening (I'd just like to overwrite any files that are there). Suggestions most welcome!

--
Scott Wilcox

@dordotky | email@hidden | http://dor.ky
+44 (0) 7538 842418 | +1 (646) 827-0580



_______________________________________________
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



--
Scott Wilcox

@dordotky | email@hidden | http://dor.ky
+44 (0) 7538 842418 | +1 (646) 827-0580


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: Excel Sheets to CSV
      • From: Scott Wilcox <email@hidden>
References: 
 >Excel Sheets to CSV (From: Scott Wilcox <email@hidden>)
 >Re: Excel Sheets to CSV (From: Leonid Bogdanov <email@hidden>)
 >Re: Excel Sheets to CSV (From: Scott Wilcox <email@hidden>)

  • Prev by Date: Re: Script to Fill Out Acrobat Forms
  • Next by Date: Re: Excel Sheets to CSV
  • Previous by thread: Re[2]: Excel Sheets to CSV
  • Next by thread: Re: Excel Sheets to CSV
  • Index(es):
    • Date
    • Thread