Save as file format CSV in Excel

Does anyone know the correct syntax on this one?
I have an excel file which should be saved as CSV.
This is what I came up with, but it doesn't run.
tell application "Microsoft Excel"
activate worksheet "worksheet1"
set fileSaveName to get save as file format CSV file format filename
save as filename fileSaveName
if fileSaveName is not "" then
display dialog "Save as " & fileSaveName
end if
end tell

It's not surprising it doesn't run but that's not entirely your fault. Excel has pone of the funkiest dictionaries around - I think they forgot to read the AppleScript Implementor's guide and instead tried to bolt VB on instead.
Anyway, I digress...
I'm not sure what you expect this line to do:
set fileSaveName to get save as file format CSV file format filename
but it's completely invalid. For one, save as is a command verb, not a function, so you cannot get save as.
If you read the dictionary for Excel's save as command you'll find:
save as sheet ¬
filename unicode text ¬
file format as ¬
password unicode text ¬
write reservation password unicode text ¬
read only recommended boolean ¬
create backup boolean ¬
add to most recently used list boolean ¬
overwrite boolean ¬
save as local language boolean
so the first, required, parameter is the sheet to save followed by any number of the optional parameters. Given the above, I'd expect your script to look more like:
tell application "Microsoft Excel"
  save as worksheet "worksheet1" file format CSV file format filename "whatever.csv"
end tell
which is completely bass-ackwards, if you ask me, but that's how it goes.

Similar Messages

  • Change default format in "save as" file format window

    I month ago I asked the following question...
    "How do I change the file format order that is listed in the "save as" file format window? Instead of having "Photoshop" listed as the default file, I'd like to have JPEG at the top, then TIFF, PSD, etc. I have to constantly scroll down the list to find JPEG."
    Recently while selecting JPEG in the "save as" format window, I accidently selected "Large Document Format" while holding down either "control", "option", "apple key", or "shift", or a combination of keys. Now the default format in the format window is "Large Document Format" (ext.PSB). I've changed the default from "Photoshop" which is still listed at the top, to "Large Document Format". I'd like to change the default to "JPEG" but I cannot replicate the correct key(s) to change the default format in the window.

    Hello TomGroup...
    I did not receive a satisfactory answer to the question. Yes, you can go
    into the Scripts but that is for experts and it is too much work.
    Aloha... Darrell
    From: TomGroupGA <[email protected]>
    Reply-To: <[email protected]>
    Date: Fri, 08 Apr 2011 12:31:07 -0600
    To: Darrell Wong <[email protected]>
    Subject: Change default format in "save as" file
    format window
    Any updates on this issue?
    I have a similar situation in that no matter what I'm working on, when I
    click "Save As' then the default format option is always .tiff    If I save
    as jpg and then go onto my next file, the default is still tiff again when I
    try to save  No matter what I try, tiff is also my default selection.  It's
    just one of those things that takes a mere 5 seconds to click the dropdown
    and select .jpg, but 5 seconds times a couple hundred files per day...it
    adds up.

  • Change "save as" file format list

    How do I change the file format order that is listed in the "save as" file format window? Instead of having "Photoshop" listed as the default file, I'd like to have JPEG at the top, then TIFF, PSD, etc. I have to constantly scroll down the list to find JPEG.

    c.pfaffenbichler wrote:
    I know of no way to change that order.
    Edit: Actually one could probably Script a dialog with a file-format-dropdown-list of one’s own devising, but that hardly seems worth the trouble.
    But with Configurator and some Scripting you can make a save-as-jpg (and save-as-psd and whatever) into a one-click operation.
    See that is exactly what I think is wrong with Configurator it allows you to some cosmetics but no real customizations there are lots of formats I do not need ever. There are things I would rather have a menu item than as a panel selection and there things I would rather have that only do a coupe of options by default but you never get the opportunity of doing these things with this program.

  • I have just bought a Panasonic Lumix compact camera. Aperture and Preview can't open the RAW files from this camera. Panasonic recommend downloading 'SYLKPIX Developer Studio SE' to save RAW file formats.How can Aperture and Preview read the files?

    I have just bought a Panasonic Lumix compact camera. Aperture and Preview can't open the RAW files from this camera. Panasonic recommend downloading 'SYLKPIX Developer Studio SE' to save RAW file formats.How can Aperture and Preview read the files?

    Either use 'SYLKPIX Developer Studio SE' to develope the RAW files and to save them in another lossless format like TIFF, or try if Adobe's free DNG Coverter can convert your Lumix RAW files to dng. Then import the dngs. This way, your files will still be RAW files.  This works (most times) for my Lumix FZ28.
    Adobe DNG Converter 8.3  http://www.adobe.com/support/downloads/detail.jsp?ftpID=5695

  • URGENT--Need to supress "Do you want to Open or save this file" for (CSV AND DOC FILES) in IE 8, IE 9 on Win XP and Win 7

    Hi 
    In our Task in Salesforce we generate one CSV file and one doc file after one button click on salesforce screen. we need to download these two documents without the popup message "Do you want to Open or save this file"
    Pls suggest Registry Edit Option Or any IE browser configuration or any
    code to get rid of this popup as this is very critical for our Task. 
    Thanks
    Kartik

    Thanks Alex... I saw this in another Forum and could you pls let me know if this works...that is there is no prompt on CSV download
    Begin in: HKEY_LOCAL_MACHINE - to change settings for all users
    HKEY_CURRENT_USER- to change settings for the current user
    Then browse to Software->Microsoft->Internet Explorer->Main->FeatureControl->Feature_Restrict_File_Download
    And then set the Value iexplore.exe to 0. If it doesn't exist: Create it (DWORD). 
    Thanks
    Kartik

  • Save as File Format  miss aligned

    When saving as  in photoshop CS6 on a mac pro  Lion 10.7.4  The File format are inncorect  I save as a tiff and get sct  I have to save as Photoshop DCS1.0 to get a tiff file  If there are a wider range of file formats available when saving an rgb formattted image  it is some times very difficult to work out which option to choose presently saving everything as psd as it is simpler.
    Also when opening files, the enable selection box is alway set to a blank  and i have to scroll down to the last two option to get "all readerble documents"   or "all documents"
    Any one eles having thes issues I have added the odd file formatt they seeme to work fine but could i assume be casusing an issue.
    File Formats:
              AdobePSDXFileLoader.plugin
              ICOFormat.plugin
              JPEG2000.plugin
              PBM.plugin
              PCX.plugin
              Pixar.plugin
              Radiance.plugin
              U3D.plugin
              WBMP.plugin
              WebPFormat.plugin
    Graeme

    Yes you are partially correct  I did go to each of the developers site and download the latest versions of the plugins  Just forgot i will have to wait a few months before they will catch up.   But to be fair the files format plugins have been fairly forgiving in previous versions obviously not in this.  I keep on having to remind myself just why i have  all these versions of photoshop on my machine.
    Never mind  its great paying for a the complete work flow solution  that falls down beacuse thirdparty developers are not up to speed ie Font Management maybe that something you should bring in house

  • HELP! Modify SAVE dialog file format options?

    Can someone please tell me how to modify the options in the save dialog?
    Every time I save a file and have to choose the file type, I have to scroll through obscure and obsolete file types. Sure, I might need someday to save Scitex CT, or Photoshop DCS, but the chances are very slim. Some people surely use PIXAR and TARGA, but I don't. What the hell is an IFF? If I ever need a Portable Bit Map (really?) file it would be great if I could find it in a user defineable option pull down. I can pretty well guarantee that the file types I need are PSD, TIFF, JPEG, PDF, PNG and once in a blue moon, GIF.
    Sure, this is a minor thing, but after years of saving thousands upon thousands of files its like being pecked to death by ducks.
    Thanks.
    Craig

    craig cheatham wrote:
    it's like being pecked to death by ducks.
    I wonder how many folks know what that really feels like...
    Do I really need to insert a smiley? 
    -Noel

  • Save to file format

    When you save your video to file in FMLE is it the input source, usually the higher quality, or the output that is saved?

    For saving the file in Excel format in the App server you have to first convert the data in XLS format and then use the transfer statement.
    You can either use FM SAP_CONVERT_TO_XLS_FORMAT for that.
    OR
    Create a comma sepreated file which will open in excel.
      open dataset file for output in text mode.
      loop at itab.
        concatenate itab-field1 itab-field2 itab-field2 into str
                      separated by ','.
        transfer str to file.
      endloop.
      close dataset file.

  • Save pdf file as csv

    I currently have a pdf file and need to save it as csv

    Cisdem PDFConverter 3.1
    Cisdem PDFtoTextConverter 3.1.0
    Cisdem PDFManagerUltimate 2.0
    Wondershare PDF Converter Pro 3.5.3
    PDF to Excel Converter 3.5.0

  • Remove unwanted save as file formats

    There are so many save as options. I'd like to remove some to make scrolling down to the ones I only use such as jpeg, Tiff, PSD etc.
    Research brought up this option, but before I blunder in are there any risks to this method or is there another "more approved" method?
    Cheers
    J

    If you have no Scripting experience you could also link to Actions from a Configurator Panel.
    Configurator is available for free:
    http://labs.adobe.com/downloads/configurator.html

  • Unable to save xls file from website in the "Microsoft Office Excel 97-2003 Worksheet" format. The browser is saving in unrecognized "File" Type

    The version I am using is 3.6.11
    The file is stored in the server in the format "Microsoft Office Excel 97-2003 Worksheet"
    But when I download it, it gets saved in the unrecognized format type "File"
    The servlet code written to download the file sets the content type to "application/vnd.ms-excel"
    I am able to save the file in Microsoft Office Excel 97-2003 Worksheet format using Internet Explorer Browser without any issues.
    But it does not work with the Mozilla Firefox. Any plug-in needed to make it work?

    Did you try to add the .xls file extension yourself to those files?

  • Tranfer table content in to excel file format

    HI
    I have Created one table .and I want to download this table in to excel file format.how can i do this.

    Hi Vijay
    1) Type the t-code SE16
    2) Type the table name, for example USR02
    3) Press F7 to view the table contents
    4) If you need filter the data in the next screen you could do it.
    5) Press F8 or press the execute bottom.
    In the next screen you will find the result.
    In the menu, follow the options:
    System->List->Save->Local File->Spreadsheet
    Type the excel name, and click generate
    Hope it helps, and please reward points if helpful
    Regards

  • Reduce the number of File Formats in Save As list

    How do I permanently remove unwanted file formats from the "save as" file format list?
    (Adobe Photoshop CS2)
    Thanks,
    Drew

    This has been asked before and as far as I know it can't be done.

  • Output report data to excel file format or csv format

    Is there any way to save softcopy of report output to excel file format or csv format.

    Hi,
    Regarding csv file format, i have no issues. The file is generating without any issues in using oracle reports without using any PL/SQL code.
    My requirement is to design oracle reports to generate excel (.xls) file with multiple worksheets. Each sheets are having many data and graphs(chart).
    Using oracle reports alone, how to achieve this.
    In oracle reports 10g 1.2.0 version, I tried by creating .rdf file but, it is generating single worksheet only.
    In oracle reports 10g 1.2.0 ver, I tried by creating .jsp file. For this first i am creating excel template about how my ouput column headings all that going to be with one sample hard coded data and save the excel file as web page.
    Eg employee.html.
    Next open the html file in oracle reports builder and double click the websource now, you will see the jsp tags, html and xml tags. Now include the contentType="application/vnd.ms-excel " and charset also.
    Next, include the <rw:foreach id="G_EMPNO_1" src="G_EMPNO">
    here insert the fieldl for each column by removing the hard coded values.
    close the tag
    </rw:foreach>
    Save the file as .jsp and deploy it in oc4 enabled folder (say, devsuite_home/reports/j2ee/reports_ids/web
    Start the oc4J server
    Run it in the browser http://server:port/reports/emp.jsp?useride=uid/pwd@db
    It is invoking the Microsoft excel with 3 sheets default and my emp table output in the first page.
    We can save this output file as .xls file by clicking file -> save as.
    1) The question is, it is working fine with Microsoft excel 97-2003 version. But for excel 2007, i am not able to create single html file like how 2003 save web page option.
    2) I found this in oracle getting started demo
    http://www.oracle.com/technology/products/reports/htdocs/getstart/demonstrations/index.html
    Which is more useful. This is what i am looking for.
    I done that in excel 2003 as per demo. But excel 2007 with reports 10g issues.
    Is there any demo for 10g with excel 2007
    3) For most of excel issues working fine with excel 2003 and 10g. But excel 2007 with 10g reports are issues.
    I want the excel output from oracle reports with multiple worksheet similar to the above demo.
    Thank you.

  • How to save from a JTable to .CSV file format?

    i am building a client sever model in which the client will send the details to the server...
    the server will take all the details and display it in a jtable..
    now, after sorting it using autorowsorter(..), how can i save the data from table to a .CSV file???
    Thanks in advance..

    Here is one code from my own my application. It should compile straight away, but if there are any compile time bugs, you can easily fix them. Pls do read the comments at the top.
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.net.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.filechooser.*;
    import javax.swing.table.*;
    * This class is now JDK 1.6 Dependent, with the addition of the use of the Desktop
    * class instead of the default application launch procedure, and the use of the new
    * FileNameExtensionFilter class introduced under javax.swing.filechooser.
    * This class can be used in one line of code by passing the appropriate JTable to the
    * desired constructor.
    public class ExcelExporter extends Object {
        public JTable source;
        public JFileChooser chooser;
        public File csvFile;
        private boolean cancelOp = false, isDefault = true;
        private String topText = "";
        public ExcelExporter(JTable source) {
            this(source, "");
        public ExcelExporter(JTable source, String topText) {
            this(source, topText, true);
        public ExcelExporter(JTable source, String topText, boolean isDefault, File target, JProgressBar bar) {
            super();
            this.source = source;
            this.topText = topText;
            this.isDefault = isDefault;
            new ProgressDialog(source, target, bar);
        public ExcelExporter(JTable source, String topText, boolean isDefault) {
            super();
            this.source = source;
            this.topText = topText;
            this.isDefault = isDefault;
            obtainFileName();
        public void obtainFileName() {
            cancelOp = false;
            FileNameExtensionFilter filter = new FileNameExtensionFilter("Excel Format (CSV)", "csv");
            if(chooser == null) {
                chooser = new JFileChooser();
                chooser.setDialogTitle("Saving Database");
                chooser.setFileFilter(filter);
                chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
                chooser.setSelectedFile( new File("database.csv") );
                chooser.setAcceptAllFileFilterUsed(false);                     
            int val = chooser.showSaveDialog((Component)null);
            if(val == JFileChooser.APPROVE_OPTION) {
                csvFile = chooser.getSelectedFile();
                boolean fixed = fixExtension(csvFile, "csv");
                if(!fixed && !cancelOp) {
                    JOptionPane.showMessageDialog(null,"File Name Specified Not Supported",
                    "File Name Error", JOptionPane.ERROR_MESSAGE);
                    obtainFileName();
                    return;
                if(!cancelOp) {
                    //storeTableAsCSV(csvFile, source);
                    new ProgressDialog(source, csvFile).setVisible(true);
        public boolean fixExtension(File file, String prefExt) {
            String fileName = file.getName();
            String dir = file.getParentFile().getAbsolutePath();
            String ext = null;
            try {
                ext = fileName.substring( fileName.lastIndexOf("."), fileName.length() );
                System.out.println("Original File Extension: " + ext);
            } catch(StringIndexOutOfBoundsException e) {
                ext = null;
            if(ext != null && !ext.equalsIgnoreCase("."+prefExt)) {
                return false;
            String csvName = null;
            if(ext == null || ext.length() == 0) {
                csvName = fileName + "." + prefExt;
            } else {
                csvName = fileName.substring(0, fileName.lastIndexOf(".") + 1) + prefExt;
            System.out.println("Corrected File Name: " + csvName);
            File csvCert = new File(dir, csvName);
            if(csvCert.exists()) {
                int val = JOptionPane.showConfirmDialog(null, "Replace Existing File?", "File Exists",
                            JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE);
                if(val == JOptionPane.NO_OPTION) {
                    obtainFileName();
                    cancelOp = true;
                    return false;
                } else if(val == JOptionPane.CANCEL_OPTION) {
                    cancelOp = true;
                    return false;              
            if(!file.renameTo(csvCert)) {
                file = new File(dir, csvName);
                try {
                    file.createNewFile();
                } catch(IOException ioe) {}
            System.out.println("Exporting as: " + file.getAbsolutePath() );
            return true;
        public void storeTableAsCSV(File target, JTable src) {
            String csvData = topText + "\n\n";
            for(int i = 0; i < src.getModel().getRowCount(); i++) {
                for(int x = 0; x < src.getModel().getColumnCount(); x++) {
                    int col = src.convertColumnIndexToView(x);
                    String curVal = (String)src.getModel().getValueAt(i,col);
                    if(curVal == null) {
                        curVal = "";
                    csvData = csvData + removeAnyCommas(curVal) + ",";
                    if(isDefault) {
                        if(x == src.getModel().getColumnCount() - 3) {
                            csvData = csvData + "\n";
                            continue;
                    } else {
                        if(x == src.getModel().getColumnCount() - 1) {
                            csvData = csvData + "\n";                      
            try {
                FileWriter writer = new FileWriter(target);
                    writer.write(csvData);
                    writer.flush();
                    writer.close();
                writer = null;
                csvData = null;
            } catch(IOException ioe) {
                JOptionPane.showMessageDialog(source, "Error Writing File.\nFile may be in use by another application."
                + "\nCheck and try re-exporting", "Export Error", JOptionPane.ERROR_MESSAGE);
        public String removeAnyCommas(String src) {
            if(src == null) {
                return "";
            for(int i = 0; i < src.length(); i++) {
                if(src.charAt(i) == ',') {
                    src = src.substring(0,i) + src.substring(i+1, src.length());
            return src;
        class ProgressDialog extends JDialog {
            JProgressBar progress;
            JLabel progressLabel;
            javax.swing.Timer timer;
            int rowPoint = -1;
            StringBuffer data;
            JTable srcTable;       
            DefaultTableModel srcModel;
            File targetFile;
            public ProgressDialog(JTable src, File target) {
                super( new JDialog(), "Exporting", true);
                createUI();
                setLocationRelativeTo(null);
                srcTable = src;
                srcModel = (DefaultTableModel)src.getModel();
                targetFile = target;
                exportDataProgressively();
            public ProgressDialog(JTable src, File target, JProgressBar progress) {
                super();
                srcTable = src;
                srcModel = (DefaultTableModel)src.getModel();
                targetFile = target;
                setProgressBar(progress);
                exportDataProgressively();
            public void createUI() {
                progress = new JProgressBar(0, 100);
                progress.setIndeterminate(true);
                progress.setValue(0);
                progress.setBorder( BorderFactory.createCompoundBorder(
                                        BorderFactory.createEmptyBorder(10,10,10,10),
                                    UIManager.getBorder("ProgressBar.border") ) );
                progress.setPreferredSize( new Dimension(300, 38) );
                progressLabel = new JLabel("Writing Excel Format. Please Wait...");
                progressLabel.setFont( new Font("Verdana", Font.PLAIN, 11) );
                progressLabel.setBorder( BorderFactory.createEmptyBorder(10,10,10,10) );
                JPanel progressPanel = new JPanel( new BorderLayout() );
                    progressPanel.add(progressLabel, BorderLayout.NORTH );
                    progressPanel.add(progress, BorderLayout.CENTER);
                    progressPanel.setBorder( BorderFactory.createEmptyBorder(10,10,10,10) );
                setContentPane(progressPanel);         
                pack();
            public void exportDataProgressively() {
                //progress.setString("");
                progress.setMaximum(srcModel.getRowCount());
                progress.setIndeterminate(false);
                data = new StringBuffer("Autogenerated Excel Format"
                     + topText + "\n\n");          
                timer = new javax.swing.Timer(15, new ActionListener() {
                    public void actionPerformed(ActionEvent e) {                   
                        if(rowPoint > -1 && srcModel.getValueAt(rowPoint,0) == null) {
                            timer.stop();
                        progress.setValue(rowPoint);
                        appendData();
                timer.setRepeats(false);
                timer.start();
            public void appendData() {
                timer.stop();
                for(int j = 0; j < srcModel.getColumnCount(); j++) {
                    int col = srcTable.convertColumnIndexToView(j);
                    if(rowPoint == -1) {
                        data.append(removeAnyCommas((String)srcModel.getColumnName(col)).toUpperCase());
                    } else if(col != -1){
                        String text = (String)srcModel.getValueAt(rowPoint,col);
                        if(srcModel.getColumnName(col).equalsIgnoreCase("Phone Number(s)") && !isPrintableText(text) ) {
                            text = "\'" + getPrintableText(text);
                        } else if( srcModel.getColumnName(col).equalsIgnoreCase("Phone Number(s)") && isPrintableText(text)  ) {
                            text = "\'" + removeAnyCommas(text);
                        } else {
                            text = removeAnyCommas(text);
                        data.append(text);
                    if(isDefault) {
                        if(j != srcModel.getColumnCount() - 3 ){
                            data.append(",");
                        } else {
                            data.append("\n");
                            break;
                    } else {
                        if(j != srcModel.getColumnCount() - 1 ){
                            data.append(",");
                        } else {
                            data.append("\n");
                rowPoint++;
                if(rowPoint < srcModel.getRowCount()) {
                    timer.start();
                } else {
                    try {
                        if(!targetFile.exists())
                            targetFile.createNewFile();
                        FileWriter writer = new FileWriter(targetFile);
                            writer.write(data.toString());
                            writer.close();
                            progress.setValue(progress.getMaximum());
                            progress.setStringPainted(true);
                            progress.setString("Done");
                            openFile(targetFile);                      
                            setVisible(false);
                            data = null;
                    } catch(IOException ioe) {
                        JOptionPane.showMessageDialog(source, "Error Writing File. Try Resaving",
                        "Save Error", JOptionPane.ERROR_MESSAGE);
                    } catch(Exception exc) {
                        System.out.println(exc);
            public void setProgressBar(JProgressBar bar) {
                progress = bar;
            public boolean isPrintableText(String text) {
                return !text.contains("::");
            public String getPrintableText(String text) {          
                try {
                    text = text.substring(2);
                } catch(StringIndexOutOfBoundsException sie) {
                    System.out.println(sie);
                String generated = "";
                StringTokenizer st = new StringTokenizer(text, ",");
                try {
                    for(int i = 0; st.hasMoreTokens(); i++ ) {
                        if(i > 0) {
                            generated = generated + " / ";
                        String token = st.nextToken();
                        generated = generated + token.substring( token.indexOf("-") + 2 );
                } catch(NoSuchElementException nse) {}
                return generated;
            public void openFile(File file) {
                int val = JOptionPane.showConfirmDialog(null, "Would You Like To View The File Right Now?",
                "View File", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE);
                try {
                    if(val == JOptionPane.YES_OPTION) {
                        if(Desktop.isDesktopSupported()) {
                            Desktop.getDesktop().open(file);
                        } else {
                            new ExcelExecutor(file.getAbsolutePath());
                } catch(IOException ioe) {
                    JOptionPane.showMessageDialog(null, "Failed to Open File", "Error",
                     JOptionPane.ERROR_MESSAGE);
    }ICE

Maybe you are looking for

  • Can I work on a a file created on iMovie 10.0.8 back in iMovie'11?

    Created a Movie with iMovie 10.0.8, and "saved" my movie and assets.  Can I edit in iMovie 11?

  • Spectral histogram of adc output

    G'day all I have a LabVIEW task that I'm confident would have been dealt with before (many times). However, not for the life of me can I find a documented solution. It involves the display of a spectrum of channel hits from an ADC on a histogram (no,

  • Can I auto login in to the iTunes store?

    I launch iTunes manually when needed and when I open it it askes me to log in to the iTunes Store. My user name is there and I have to enter my password. Anyway to have the password there also so I don't have to enter it every time? Is there a Save P

  • Every page I open in Firefox looks cramped.

    Every page I open in Firefox looks like the formatting is wrong. Even this page...the fields overlap. Particularly if it is a retail/shopping site, I can hardly read product descriptions or whatever because everything is on top of each other. Picture

  • How to register HPLJ6L in 11i

    I have install 11i vis demo in windows2000 server , but how to register printer ? My printer is HPLJ6L Pro . And I didn't find suitable print type in vis database , where could I find the driver or type , how to register it ! Thank you !