You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A common development flow for tables is to look at the final product in Word, then iterate the code. An annoying thing about this process is having to manually close the open document before saving. browseURL() can automatically open a file, but we have no way to automatically close a file. o1-preview offered this solution for Windows which may provide some inspiration:
# Replace with the name of your Word documentdocName<-"YourDocumentName.docx"# Create the PowerShell script as a stringpsScript<- sprintf('$word = [Runtime.InteropServices.Marshal]::GetActiveObject("Word.Application")foreach ($doc in $word.Documents) { if ($doc.Name -eq "%s") { $doc.Close() }}', docName)
# Write the PowerShell script to a temporary filepsFile<- tempfile(fileext=".ps1")
writeLines(psScript, psFile)
# Execute the PowerShell script
system2("powershell", args= c("-ExecutionPolicy", "Bypass", "-File", psFile))
# Optionally, delete the temporary PowerShell script file
file.remove(psFile)
The text was updated successfully, but these errors were encountered:
A common development flow for tables is to look at the final product in Word, then iterate the code. An annoying thing about this process is having to manually close the open document before saving.
browseURL()
can automatically open a file, but we have no way to automatically close a file. o1-preview offered this solution for Windows which may provide some inspiration:The text was updated successfully, but these errors were encountered: