ruby-docx / docx

a ruby library/gem for interacting with .docx files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

undefined method `close' for nil:NilClass

JonasPreisler opened this issue · comments

I wrote this simple code:

require 'docx'

# Create a Docx::Document object for our existing docx file
doc = Docx::Document.open("a.docx")

# Retrieve and display paragraphs
doc.paragraphs.each do |p|
  puts p
end

...and keep getting "undefined method `close' for nil:NilClass".

I am sure the file is there, and tried many different locations for the file, so I'm suspecting this gem is not maintained.

Can anyone guide me? Thank you

Sorry, it worked when I used a real docx file. I just changed the file extension to "docx", but only after using a file from here, it worked: https://file-examples.com/index.php/sample-documents-download/sample-doc-download/