Cannot install SWinTypeLibs, but need to know what functions are in ComCreate(Word.Application)

185 Views Asked by At

Please forgive me if this is not perfect but this is my first post.

I am currently working on trying to transform a large number of .docx documents into .pdf

I have found the RDCOMClient package which has done wonders. However I now need to add alt text into my charts. The code I am using is below:

library(RDCOMClient)
library(plyr)
library(tidyverse)

# this will destroy all objects in your workspace so be careful
# rm(list = ls()) # deletes all data frames

file <- "directory"

wordApp <- COMCreate("Word.Application")  # create COM object
wordApp[["Visible"]] <- FALSE #opens a Word application instance visibly if true 
wordApp[["Documents"]]$Add() #adds new blank docx in your application
wordApp[["Documents"]]$Open(Filename=file) #opens your docx in wordApp

#THIS IS THE MAGIC    
wordApp[["ActiveDocument"]]$SaveAs("Directory", 
                                   FileFormat=17) #FileFormat=17 saves as .PDF

wordApp[["ActiveDocument"]]$Close(SaveChanges = 1) # says there are no changes that need saving

Where there is function in double [] like Documents is there something for chart.

I have found a full list of them for excel at the link here: http://www.omegahat.net/RDCOMClient/Docs/introduction.html

However I tried to install the SWinTypeLibs package to get the same thing for word using the following code:

install.packages("remotes")
remotes::install_github("omegahat/SWinTypeLibs")

and keep getting an error

if anyone has a list for word like the excel above would really need it.

Thanks for all the help in advance.

James

1

There are 1 best solutions below

0
On

I've applied a quick fix to the .Rd docs in the original package from omegahat. You can find it here--should compile now.

karnner2/SWinTypeLibs

devtools::install_github("Karnner2/SWinTypeLibs")