0

I have the following code which uses the existing and open Excel application. How to I force R to open a new Excel application and open the workbook in this new Excel station?

xlApp <- COMCreate("Excel.Application")
xlWbk <- xlApp$Workbooks()$Open("S:/x/z/y.xlsb")
xlApp[['Visible']] <- TRUE 
jogo
  • 12,469
  • 11
  • 37
  • 42
Jeweller89
  • 19
  • 1
  • 5
  • You don't need Excel to read or write Excel files. `xlsx` is a zip package containing XML files. You can use packages like openxlsx or xlsx to open them – Panagiotis Kanavos Nov 20 '18 at 09:57
  • The spreadsheet are saved in binary formats (xlsb) and runs a open_workbook macro which is executed and then the workbook is closed. My problem is simply that I would need it to run in a seperate Excel application if possible. – Jeweller89 Nov 20 '18 at 10:40
  • Do you want to open a new excel workbook or you want to force R to open the same workbook? – Vishal Sharma Feb 14 '22 at 05:48

1 Answers1

0

You can consider the following approach :

library(RDCOMClient)

path1 <- "D:\\test1.xlsx"
path2 <- "D:\\test2.xlsx"

xlApp1 <- COMCreate("Excel.Application")
xlWbk1 <- xlApp$Workbooks()$Open(path1)
xlApp1[['Visible']] <- TRUE 

xlApp2 <- COMCreate("Excel.Application")
xlWbk2 <- xlApp$Workbooks()$Open(path2)
xlApp2[['Visible']] <- TRUE 
Emmanuel Hamel
  • 1,769
  • 7
  • 19