【发布时间】:2022-01-11 03:56:23
【问题描述】:
如果这不是完美的,请原谅我,但这是我的第一篇文章。
我目前正在尝试将大量 .docx 文档转换为 .pdf
我发现 RDCOMClient 包创造了奇迹。但是我现在需要在我的图表中添加替代文本。我使用的代码如下:
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
像 Documents 这样的 double [] 中有函数的地方是图表。
我在此处的链接中找到了完整的 excel 列表:http://www.omegahat.net/RDCOMClient/Docs/introduction.html
但是我尝试使用以下代码安装 SWinTypeLibs 包以获得相同的单词:
install.packages("remotes")
remotes::install_github("omegahat/SWinTypeLibs")
并不断收到错误
如果有人有像上面的 excel 这样的单词列表真的需要它。
提前感谢所有帮助。
詹姆斯
【问题讨论】:
-
也急于列出所有的 com 对象方法
标签: r vba rdcomclient