0

I kept on receiving the error message when trying to export the flextable to word document.

Example:

doc <- read_docx() Error in utils::unzip(file, exdir = tmp) : argument "file" is missing, with no default doc <- body_add_flextable(doc,value=t13,align = "center",split = TRUE) Error in inherits(x, "rdocx") : object 'doc' not found print(doc,target = "Table13.docx") Error in print(doc, target = "Table13.docx") : object 'doc' not found

Among all the errors returned, it seems read_docx() function is not applied correctly. I have no idea how to fix it. Anyone has any ideas? Thanks!

J.Davis
  • 1
  • 2
  • 1
    Could be one of problems: 1. the function read_docx maybe overwritten by another package. Does it work if you do `doc <- officer::read_docx()` 2. Or a rights issue. When I look at read_docx, it looks like it creates a temporary empty document, and then reads that. If it cannot read that temporary file, an error occurs. – Emil Bode Dec 10 '18 at 23:12
  • If you execute `doc<-read_docx()` again and then immediately type `traceback()`, what do you get? It tells you where exactly the error occurs. – Emil Bode Dec 10 '18 at 23:13
  • Hi Emil@Emil Bode, thank you for the solution! doc <- officer::read_docx() really works! Also, as you suggested, I executed doc <- read_docx(), and type traceback(), what I got is : > doc<-read_docx() Error in utils::unzip(file, exdir = tmp) : argument "file" is missing, with no default > traceback() 2: utils::unzip(file, exdir = tmp) 1: read_docx() looks like the read_docx maybe overwritten by another package. – J.Davis Dec 12 '18 at 17:05
  • BTW, if you want to know which package is overwriting it, you can use `getAnywhere('read_docx')`, this will give you extensive information of which objects there are out there under that name. – Emil Bode Dec 12 '18 at 18:41
  • And if you get tired of typing `officer::read_docx` all the time, you can reassign it in your global environment: `read_docx <- officer::read_docx`. Then it's the first item to be found. – Emil Bode Dec 12 '18 at 18:43
  • thanks! they are really helpful.@Emil Bode – J.Davis Dec 12 '18 at 18:58

0 Answers0