insert macros in excel using R or cmd
<p>I have the following problem: R script creates <code>.xlsx</code> file with a table where one of the columns is comprised of images (one image per cell) using <code>openxlsx</code> library. I need to align images in the center of the corresponding cells which seem to be impossible to do by means of <code>openxlsx</code> package. Therefore, I have written a simple <code>VB script(macro)</code> which may do it and want to embed this macro in excel using R or cmd(since R may call system comands). 
Could it be possible?</p>

<p>Here is the macro if it is needed:</p>

<pre><code>Sub mymacro()
 Dim Ran As Range
 Dim Sh As Shape
 For Each Sh In ActiveSheet.Shapes
  Set Ran = Sh.TopLeftCell
  Sh.Left = Ran.Left + (Ran.Width - Sh.Width) / 2
  Sh.Top = Ran.Top + (Ran.Height - Sh.Height) / 2
 Next Sh
End Sub
</code></pre>