Re: [R] shell and shell.exec on Windows
The system() function has an invisible= argument. The ryacas package uses system() to run yacas. See the runYacas() and yacasInvokeString() functions in yacas.R for examples: http://ryacas.googlecode.com/svn/trunk/R/yacas.R On 8/11/07, Erich Neuwirth [EMAIL PROTECTED] wrote: I have an Excel workbook MyWorkbook.xls containing an Auto_Open macro which I want to be run from R. shell.exec(MyWorkbook.xls) does that. shell(start MyWorkbook.xls) also runs it. In both cases, the Excel window is visible on screen when Excel is started. Is there a way of opening the sheet with a hidden Excel window? start has some parameters (e.g. /MIN), which should allow this, but shell(start /MIN MyWorkbook.xls) also starts Excel visibly. -- Erich Neuwirth, University of Vienna Faculty of Computer Science Computer Supported Didactics Working Group Visit our SunSITE at http://sunsite.univie.ac.at Phone: +43-1-4277-39464 Fax: +43-1-4277-39459 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] shell and shell.exec on Windows
Thanks Gabor, system() indeed would be the answer, but it does not solve my problem because of some inconsistencies in WindowsXP. I will explain the story, because perhaps it can help somebody else to avoid wasting time. On my machine, when I doubleclick an .xlsm file, it is opened in Excel 2007. .xls files are opened in Excel 2003. shell.exec(file.xls) and shell.exec(file.xlsm) also open the files in Excel 2003 and Excel 2007 respectively. system() does not invoke a shell, so I need to find the application associated with Excel to create a string with the name of the application and the name of the file to open. Then, something like system(\c:\\mypath\\CorrectVersionOfExcel.exe\ \c:\\mydir\\myexcelfile.xlsm\) should work (and run the program invisibly) There are two helpful shell commands in WinXP ASSOC and FTYPE ASSOC .xls .xls=Excel.Sheet.8 ASSOC .xlsm .xlsm=Excel.SheetMacroEnabled.12 ftype Excel.Sheet.8 Excel.Sheet.8=C:\Program Files\Microsoft Office\OFFICE11\EXCEL.EXE /e ftype Excel.SheetMacroEnabled.12 Excel.SheetMacroEnabled.12=C:\PROGRA~2\MICROS~2\OFFICE11\EXCEL.EXE /e So despite the fact that doubleclicking .xlsm files or using shell.exec opens Excel 2007 the application reported by assoc and ftype for .xlsm files is Excel 2003. Gabor Grothendieck wrote: The system() function has an invisible= argument. The ryacas package uses system() to run yacas. See the runYacas() and yacasInvokeString() functions in yacas.R for examples: http://ryacas.googlecode.com/svn/trunk/R/yacas.R On 8/11/07, Erich Neuwirth [EMAIL PROTECTED] wrote: I have an Excel workbook MyWorkbook.xls containing an Auto_Open macro which I want to be run from R. shell.exec(MyWorkbook.xls) does that. shell(start MyWorkbook.xls) also runs it. In both cases, the Excel window is visible on screen when Excel is started. Is there a way of opening the sheet with a hidden Excel window? start has some parameters (e.g. /MIN), which should allow this, but shell(start /MIN MyWorkbook.xls) also starts Excel visibly. -- Erich Neuwirth, University of Vienna Faculty of Computer Science Computer Supported Didactics Working Group Visit our SunSITE at http://sunsite.univie.ac.at Phone: +43-1-4277-39464 Fax: +43-1-4277-39459 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Erich Neuwirth, University of Vienna Faculty of Computer Science Computer Supported Didactics Working Group Visit our SunSITE at http://sunsite.univie.ac.at Phone: +43-1-4277-39464 Fax: +43-1-4277-39459 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] shell and shell.exec on Windows
If you are using Windows, then try: system('cmd /c yourfile.xls') This will invoke the windows command processor and it should pick the correct association. On 8/11/07, Erich Neuwirth [EMAIL PROTECTED] wrote: Thanks Gabor, system() indeed would be the answer, but it does not solve my problem because of some inconsistencies in WindowsXP. I will explain the story, because perhaps it can help somebody else to avoid wasting time. On my machine, when I doubleclick an .xlsm file, it is opened in Excel 2007. .xls files are opened in Excel 2003. shell.exec(file.xls) and shell.exec(file.xlsm) also open the files in Excel 2003 and Excel 2007 respectively. system() does not invoke a shell, so I need to find the application associated with Excel to create a string with the name of the application and the name of the file to open. Then, something like system(\c:\\mypath\\CorrectVersionOfExcel.exe\ \c:\\mydir\\myexcelfile.xlsm\) should work (and run the program invisibly) There are two helpful shell commands in WinXP ASSOC and FTYPE ASSOC .xls .xls=Excel.Sheet.8 ASSOC .xlsm .xlsm=Excel.SheetMacroEnabled.12 ftype Excel.Sheet.8 Excel.Sheet.8=C:\Program Files\Microsoft Office\OFFICE11\EXCEL.EXE /e ftype Excel.SheetMacroEnabled.12 Excel.SheetMacroEnabled.12=C:\PROGRA~2\MICROS~2\OFFICE11\EXCEL.EXE /e So despite the fact that doubleclicking .xlsm files or using shell.exec opens Excel 2007 the application reported by assoc and ftype for .xlsm files is Excel 2003. Gabor Grothendieck wrote: The system() function has an invisible= argument. The ryacas package uses system() to run yacas. See the runYacas() and yacasInvokeString() functions in yacas.R for examples: http://ryacas.googlecode.com/svn/trunk/R/yacas.R On 8/11/07, Erich Neuwirth [EMAIL PROTECTED] wrote: I have an Excel workbook MyWorkbook.xls containing an Auto_Open macro which I want to be run from R. shell.exec(MyWorkbook.xls) does that. shell(start MyWorkbook.xls) also runs it. In both cases, the Excel window is visible on screen when Excel is started. Is there a way of opening the sheet with a hidden Excel window? start has some parameters (e.g. /MIN), which should allow this, but shell(start /MIN MyWorkbook.xls) also starts Excel visibly. -- Erich Neuwirth, University of Vienna Faculty of Computer Science Computer Supported Didactics Working Group Visit our SunSITE at http://sunsite.univie.ac.at Phone: +43-1-4277-39464 Fax: +43-1-4277-39459 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Erich Neuwirth, University of Vienna Faculty of Computer Science Computer Supported Didactics Working Group Visit our SunSITE at http://sunsite.univie.ac.at Phone: +43-1-4277-39464 Fax: +43-1-4277-39459 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.