title: Add Macro to Excel file from R
body: <p>I am using RDCOMClient package in R. I am able to run existing Macro in Excel Workbook from R. Is there a simple way to add Macro to Excel Workbook, when Macro is written in simple ".txt" file?</p>
  
  <p>So far I have:</p>
  
  <pre><code>library(RDCOMClient)
  xlApp &lt;- COMCreate("Excel.Application")
  xlWbk &lt;- xlApp$Workbooks()$Open(normalizePath(list.files(pattern=".xlsm")[1])) 
  ### open first xlsm file in working directory
  xlApp$Run("Send") ## Run existing Macro named "Send"
  
  can i do something like xlApp$AddMacro("myMacro.txt") to add new Macro to the workbook?
  </code></pre>
  
  <p>Thanks.</p>
  
  <p>EDIT: I manage to add empty module and name it, but somehow I cannot add actually code to it:</p>
  
  <pre><code>mo &lt;- xlApp$Modules()$Add()
  mo[["Name"]] &lt;- "Test"
  smth like mo[["Body??"]]
  </code></pre>