Open a word document and apply a macro

Hi All,

I'm working with RMarkdown for the first time and thanks to a bit of learning of how flextable works etc. I've matched the internal house style for a report which goes to our senior management team.

The only leftover piece is the formatting of the tables. flextable does so excellent work but I have no way to call the functionality of Word's Autofit to window funciton. Which tidy's a table to a more presentable style (prevents word splitting over lines and wraps text in column headers).

There doesn't appear to be a way to do this within flextable or RMarkdown.

I've been trying to use the RDCOMClient after outputting to open the resulting word document and apply a macro that just sets all tables to autofit to window but can't seem to get it to actually open the word document.

Has anyone any experience or can offer an alternative solution? The tables can be different in terms of column spacing as a result of params set for Rmarkdown.

1 Like

I don't have experience with this exact issue. But in the past when I've needed to call macros in Access or Excel, I have written a VB script to do it. Then the script gets invoked from R.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.