after downloading a .doc file from website it shows html code instead of it contents

After downloading a .doc file from the web it shows HTML code instead of its contents.
It appears in LibreOffice Writer like this:-

and on WPS Office it proves the actual data like this:-

I want to know what shall be done in order to open the same file in LibreOffice Writer so that it will provide the desired content of the file.

LibreOffice Writer version: 6.3.5.2
OS: Fedora 31 Workstation

Please let me know if any other information is required.
Kindly help.

Try renaming that “.DOCX” into proper “.HTML”.

Thanks for the suggestion,

I tried this but even after changing its extension to .html things didn’t change. Anything else we can try??

Do help.

Try opening the file in Calc specifying HTML export as the file type.

even after changing its extension to .html things didn’t change.

Typically, this happens when you change file type by open + save as in Writer. For a file which opens properly, this is a good procedure.

In this case the most likely cause of error is that the file is saved as html, but using the doc extension. This confuses the software’s selection of import filter (file content interpreter).

  • MS Word uses the file content to make assumptions towards file format and picks import filter from that. This hits home most of the time.
  • WPS Office uses MS Office libraries, or so I have heard. Behaves much the same.
  • LibreOffice uses the filename extension to pick the correct import filter.

This makes LibreOffice more vulnerable to fault in that extension.

If this is the cause in the case at hand, the solution is to change extension using the file manager in Windows. Alas, its default setting is to hide the extension for known types. You need to disable that first

@keme: OP mentions he uses Fedora Linux 31!

@debajiteziodutta: click once on the file icon, hit F2 and change the extension to html.

@keme : if “LibreOffice uses the filename extension to pick the correct import filter”, then renaming would solve the problem, no?

if “LibreOffice uses the filename extension to pick the correct import filter”, then renaming would solve the problem, no?

@mikekaganski : Sure! My point was that it is not uncommon for users to use the Office suite to change this extension, so the file “save format” is changed in the process, essentially keeping the wrong output. I just explained the difference between resave and rename, and (at least I thought that I) gave explicit guidelines towards rename. (Wrong OS, though. My bad!)

OP mentions he uses Fedora Linux 31!

@ajlittoz : Yes, I missed that. Thanks for notifying me and providing proper advice to the OP. @debajiteziodutta : Please accept my apology!

“click once on the file icon, hit F2 and change the extension to html.”

@ajlittoz: Thank you for the help. I tried that but the situation remains the same. If there are any other suggestions, then do provide.

@keme: No need to apologize, we all here are trying to help each other after all. Thank You for the information.

I suppose that LibreOffice does not recognize it as HTML because it does not start with usual HTML things like xml declaration, or DTD, or <html> tag. I assume that simply wrapping the file into <html><body>/</body></html> will fix that.

I’m unsure if LibreOffice’s behaviour is wrong. Expecting that HTML markup suddenly appearing in the middle of an arbitrary content, would magically make it HTML, is wrong IMO (even not taking into account the extension tweaking). Whoever had prepared that “document” was heavily relying on specifics of some single product behaviour in non-standard conditions. Other products may or may not do the same in those conditions, and the proper way would be to create a proper document.

Running Windoes 10 here.
I have the same problem. I switched to Libre because Apache Open Office was having trouble loading a couple of the Doc files I was downloading and a person suggested I switch as they had some success with opening them. Renaming to DOCX does nothing, renaming to HTML does work on some of them. I suspect the answer is already here in that the import module is confused on some documents.

Do not answer a question unless it is a real answer.